Fixed statistics recovery after controller reload/restart

This commit is contained in:
Thulinma 2017-01-07 12:12:24 +01:00
parent c6377085f0
commit 88834e53ba

View file

@ -807,11 +807,15 @@ namespace IPC {
///\brief Creates the next page with the correct size ///\brief Creates the next page with the correct size
void sharedServer::newPage() { void sharedServer::newPage() {
sharedPage tmp(std::string(baseName.substr(1) + (char)(myPages.size() + (int)'A')), std::min(((8192 * 2) << myPages.size()), (32 * 1024 * 1024)), true); sharedPage tmp(std::string(baseName.substr(1) + (char)(myPages.size() + (int)'A')), std::min(((8192 * 2) << myPages.size()), (32 * 1024 * 1024)), false);
if (!tmp.mapped){
tmp.init(std::string(baseName.substr(1) + (char)(myPages.size() + (int)'A')), std::min(((8192 * 2) << myPages.size()), (32 * 1024 * 1024)), true);
tmp.master = false;
}
myPages.push_back(tmp); myPages.push_back(tmp);
tmp.master = false; myPages.back().master = true;
DEBUG_MSG(DLVL_VERYHIGH, "Created a new page: %s", tmp.name.c_str()); VERYHIGH_MSG("Created a new page: %s", tmp.name.c_str());
amount += tmp.len / (payLen + (hasCounter ? 1 : 0)) - 1; amount += (32 * 1024 * 1024)*myPages.size();//assume maximum load - we don't want to miss any entries
} }
///\brief Deletes the highest allocated page ///\brief Deletes the highest allocated page
@ -982,12 +986,12 @@ namespace IPC {
if (countNum == 127 || countNum == 126){ if (countNum == 127 || countNum == 126){
semGuard tmpGuard(&mySemaphore); semGuard tmpGuard(&mySemaphore);
if (disconCallback){ if (disconCallback){
disconCallback(it->mapped + offset + 1, payLen, id); disconCallback(counter + 1, payLen, id);
} }
memset(it->mapped + offset + 1, 0, payLen); memset(counter + 1, 0, payLen);
it->mapped[offset] = 0; *counter = 0;
} else { } else {
it->mapped[offset] ++; ++(*counter);
} }
} else { } else {
//stop if we're past the amount counted and we're empty //stop if we're past the amount counted and we're empty