improved controller restart stats recovery mechanism
This commit is contained in:
parent
e10a22503d
commit
dab1b74ad5
1 changed files with 12 additions and 8 deletions
|
@ -757,7 +757,6 @@ namespace IPC {
|
||||||
///\param len The lenght of the payload
|
///\param len The lenght of the payload
|
||||||
///\param withCounter Whether the content should have a counter
|
///\param withCounter Whether the content should have a counter
|
||||||
void sharedServer::init(std::string name, int len, bool withCounter) {
|
void sharedServer::init(std::string name, int len, bool withCounter) {
|
||||||
amount = 0;
|
|
||||||
if (mySemaphore) {
|
if (mySemaphore) {
|
||||||
mySemaphore.close();
|
mySemaphore.close();
|
||||||
}
|
}
|
||||||
|
@ -781,6 +780,7 @@ namespace IPC {
|
||||||
}
|
}
|
||||||
mySemaphore.post();
|
mySemaphore.post();
|
||||||
semGuard tmpGuard(&mySemaphore);
|
semGuard tmpGuard(&mySemaphore);
|
||||||
|
amount = 0;
|
||||||
newPage();
|
newPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,6 +811,7 @@ namespace IPC {
|
||||||
myPages.push_back(tmp);
|
myPages.push_back(tmp);
|
||||||
tmp.master = false;
|
tmp.master = false;
|
||||||
DEBUG_MSG(DLVL_VERYHIGH, "Created a new page: %s", tmp.name.c_str());
|
DEBUG_MSG(DLVL_VERYHIGH, "Created a new page: %s", tmp.name.c_str());
|
||||||
|
amount += tmp.len / (payLen + (hasCounter ? 1 : 0)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Deletes the highest allocated page
|
///\brief Deletes the highest allocated page
|
||||||
|
@ -861,7 +862,7 @@ namespace IPC {
|
||||||
do{
|
do{
|
||||||
parseEach(killStatistics);
|
parseEach(killStatistics);
|
||||||
Util::wait(250);
|
Util::wait(250);
|
||||||
}while(amount && c++ < 10);
|
}while(amount>1 && c++ < 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Returns a pointer to the data for the given index.
|
///Returns a pointer to the data for the given index.
|
||||||
|
@ -914,6 +915,7 @@ namespace IPC {
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
unsigned int userCount = 0;
|
unsigned int userCount = 0;
|
||||||
unsigned int emptyCount = 0;
|
unsigned int emptyCount = 0;
|
||||||
|
unsigned int lastFilled = 0;
|
||||||
connectedUsers = 0;
|
connectedUsers = 0;
|
||||||
for (std::deque<sharedPage>::iterator it = myPages.begin(); it != myPages.end(); it++) {
|
for (std::deque<sharedPage>::iterator it = myPages.begin(); it != myPages.end(); it++) {
|
||||||
if (!it->mapped || !it->len) {
|
if (!it->mapped || !it->len) {
|
||||||
|
@ -932,6 +934,7 @@ namespace IPC {
|
||||||
connectedUsers++;
|
connectedUsers++;
|
||||||
}
|
}
|
||||||
char countNum = (*counter) & 0x7F;
|
char countNum = (*counter) & 0x7F;
|
||||||
|
lastFilled = id;
|
||||||
if (id >= amount) {
|
if (id >= amount) {
|
||||||
amount = id + 1;
|
amount = id + 1;
|
||||||
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
|
@ -986,10 +989,10 @@ namespace IPC {
|
||||||
}
|
}
|
||||||
} 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
|
||||||
if (id >= amount - 1) {
|
if (id >= amount) {
|
||||||
//bring the counter down if this was the last element
|
//bring the counter down if this was the last element
|
||||||
if (id == amount - 1) {
|
if (lastFilled+1 < amount) {
|
||||||
amount = id;
|
amount = lastFilled+1;
|
||||||
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
//stop, we're guaranteed no more pages are full at this point
|
//stop, we're guaranteed no more pages are full at this point
|
||||||
|
@ -1000,6 +1003,7 @@ namespace IPC {
|
||||||
if (memcmp(empty, it->mapped + offset, payLen)) {
|
if (memcmp(empty, it->mapped + offset, payLen)) {
|
||||||
++userCount;
|
++userCount;
|
||||||
//increase the count if needed
|
//increase the count if needed
|
||||||
|
lastFilled = id;
|
||||||
if (id >= amount) {
|
if (id >= amount) {
|
||||||
amount = id + 1;
|
amount = id + 1;
|
||||||
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
|
@ -1007,10 +1011,10 @@ namespace IPC {
|
||||||
callback(it->mapped + offset, payLen, id);
|
callback(it->mapped + offset, payLen, id);
|
||||||
} 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
|
||||||
if (id >= amount - 1) {
|
if (id >= amount) {
|
||||||
//bring the counter down if this was the last element
|
//bring the counter down if this was the last element
|
||||||
if (id == amount - 1) {
|
if (lastFilled+1 < amount) {
|
||||||
amount = id;
|
amount = lastFilled+1;
|
||||||
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
VERYHIGH_MSG("Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
//stop, we're guaranteed no more pages are full at this point
|
//stop, we're guaranteed no more pages are full at this point
|
||||||
|
|
Loading…
Add table
Reference in a new issue