Made sharedServer::finishEach explicit
This commit is contained in:
parent
357eb4e722
commit
a4f35ca11e
3 changed files with 13 additions and 13 deletions
|
@ -22,6 +22,11 @@
|
|||
#endif
|
||||
|
||||
|
||||
/// Forces a disconnect to all users.
|
||||
static void killStatistics(char * data, size_t len, unsigned int id){
|
||||
(*(data - 1)) = 126;//Send disconnect message;
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||
|
@ -776,7 +781,6 @@ namespace IPC {
|
|||
|
||||
///\brief The deconstructor
|
||||
sharedServer::~sharedServer() {
|
||||
finishEach();
|
||||
mySemaphore.close();
|
||||
mySemaphore.unlink();
|
||||
}
|
||||
|
@ -833,21 +837,16 @@ namespace IPC {
|
|||
return false;
|
||||
}
|
||||
|
||||
///Disconnect all connected users
|
||||
///Disconnect all connected users, waits at most 2.5 seconds until completed
|
||||
void sharedServer::finishEach(){
|
||||
if (!hasCounter){
|
||||
return;
|
||||
}
|
||||
for (std::set<sharedPage>::iterator it = myPages.begin(); it != myPages.end(); it++) {
|
||||
if (!it->mapped || !it->len) {
|
||||
break;
|
||||
}
|
||||
unsigned int offset = 0;
|
||||
while (offset + payLen + (hasCounter ? 1 : 0) <= it->len) {
|
||||
it->mapped[offset] = 126;
|
||||
offset += payLen + (hasCounter ? 1 : 0);
|
||||
}
|
||||
}
|
||||
unsigned int c = 0;//to prevent eternal loops
|
||||
do{
|
||||
parseEach(killStatistics);
|
||||
Util::wait(250);
|
||||
}while(amount && c++ < 10);
|
||||
}
|
||||
|
||||
///Returns a pointer to the data for the given index.
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace IPC {
|
|||
///\brief The amount of connected clients
|
||||
unsigned int amount;
|
||||
unsigned int connectedUsers;
|
||||
void finishEach();
|
||||
private:
|
||||
bool isInUse(unsigned int id);
|
||||
void newPage();
|
||||
|
@ -200,7 +201,6 @@ namespace IPC {
|
|||
semaphore mySemaphore;
|
||||
///\brief Whether the payload has a counter, if so, it is added in front of the payload
|
||||
bool hasCounter;
|
||||
void finishEach();
|
||||
};
|
||||
|
||||
///\brief The client part of a server/client model for shared memory.
|
||||
|
|
|
@ -396,6 +396,7 @@ namespace Mist {
|
|||
} else if (everHadPush && !resumeMode && config->is_active) {
|
||||
INFO_MSG("Shutting down buffer because resume mode is disabled and the source disconnected");
|
||||
config->is_active = false;
|
||||
userPage.finishEach();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue