- attempt to fix the segfault reported by tomreyn when headless admin disconnects from the server
This commit is contained in:
parent
848b5fed07
commit
c14c9ebc2d
|
@ -1361,7 +1361,7 @@ void ServerInterface::update() {
|
||||||
int iFirstConnectedSlot = -1;
|
int iFirstConnectedSlot = -1;
|
||||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
|
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
|
||||||
if(slots[i] != NULL) {
|
if(slots[i] != NULL && slots[i]->isConnected() == true) {
|
||||||
if(iFirstConnectedSlot < 0) {
|
if(iFirstConnectedSlot < 0) {
|
||||||
iFirstConnectedSlot = i;
|
iFirstConnectedSlot = i;
|
||||||
}
|
}
|
||||||
|
@ -1375,15 +1375,19 @@ void ServerInterface::update() {
|
||||||
if(foundAdminSlot == false && iFirstConnectedSlot >= 0) {
|
if(foundAdminSlot == false && iFirstConnectedSlot >= 0) {
|
||||||
printf("Switching masterserver admin to slot#%d...\n",iFirstConnectedSlot);
|
printf("Switching masterserver admin to slot#%d...\n",iFirstConnectedSlot);
|
||||||
|
|
||||||
|
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[iFirstConnectedSlot],CODE_AT_LINE_X(iFirstConnectedSlot));
|
||||||
|
if(slots[iFirstConnectedSlot] != NULL) {
|
||||||
string sMsg = "Switching player to admin mode: " + slots[iFirstConnectedSlot]->getName();
|
string sMsg = "Switching player to admin mode: " + slots[iFirstConnectedSlot]->getName();
|
||||||
sendTextMessage(sMsg,-1, true,"");
|
sendTextMessage(sMsg,-1, true,"");
|
||||||
|
|
||||||
this->gameSettings.setMasterserver_admin(slots[iFirstConnectedSlot]->getSessionKey());
|
this->gameSettings.setMasterserver_admin(slots[iFirstConnectedSlot]->getSessionKey());
|
||||||
this->gameSettings.setMasterserver_admin_faction_index(slots[iFirstConnectedSlot]->getPlayerIndex());
|
this->gameSettings.setMasterserver_admin_faction_index(slots[iFirstConnectedSlot]->getPlayerIndex());
|
||||||
|
|
||||||
|
safeMutexSlot.ReleaseLock();
|
||||||
this->broadcastGameSetup(&this->gameSettings);
|
this->broadcastGameSetup(&this->gameSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//printf("\nServerInterface::update -- G\n");
|
//printf("\nServerInterface::update -- G\n");
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user