media_server: Check BMessenger validity

* Check BMessenger::IsValid on the instance
  used to query the nodes so that crashed
  teams are identified as soon as possible.
This commit is contained in:
Dario Casalinuovo
2015-07-24 12:19:35 +02:00
parent 61a59e87d8
commit 4a99aae9e4
+17 -11
View File
@@ -192,8 +192,6 @@ void
AppManager::_BigBrother() AppManager::_BigBrother()
{ {
status_t status = B_TIMED_OUT; status_t status = B_TIMED_OUT;
BMessage ping('PING');
BMessage reply;
do { do {
if (!Lock()) if (!Lock())
@@ -202,21 +200,29 @@ AppManager::_BigBrother()
bool startOver = false; bool startOver = false;
AppMap::iterator iterator = fMap.begin(); AppMap::iterator iterator = fMap.begin();
for (; iterator != fMap.end(); iterator++) { for (; iterator != fMap.end(); iterator++) {
reply.what = 0; // No need to send the alive message
status = iterator->second.SendMessage(&ping, &reply, 5000000, // if the team died.
2000000); if (iterator->second.IsValid() == true) {
if (status != B_OK || reply.what != 'PONG') { BMessage ping('PING');
team_id team = iterator->first; BMessage reply;
Unlock(); reply.what = 0;
status = iterator->second.SendMessage(&ping, &reply, 5000000,
_TeamDied(team); 2000000);
if (status != B_OK || reply.what != 'PONG') {
startOver = true;
break;
}
} else {
startOver = true; startOver = true;
break; break;
} }
} }
if (startOver) if (startOver == true) {
Unlock();
_TeamDied(iterator->first);
continue; continue;
}
Unlock(); Unlock();
status = acquire_sem_etc(fQuit, 1, B_RELATIVE_TIMEOUT, 2000000); status = acquire_sem_etc(fQuit, 1, B_RELATIVE_TIMEOUT, 2000000);