shutdown_media_server: Rework shutdown process
* Fixes issues with launch_daemon restart. * Rely on what the actual response from the server is instead to naively try to kill it. * Remove snoozing and make the restart process very fast. * Any app should rely on notifications anyway. * Due to some reason a few months ago the media_addon_server locked up very often making the notification service unreliable, today this issue looks like solved. This made possible the recent improvements.
This commit is contained in:
parent
8c7bdb72ae
commit
99741be9f2
@ -1268,13 +1268,13 @@ progress_shutdown(int stage,
|
|||||||
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
|
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
string = B_TRANSLATE("Telling media_addon_server to quit.");
|
string = B_TRANSLATE("Waiting for media_server to quit.");
|
||||||
break;
|
break;
|
||||||
case 40:
|
case 40:
|
||||||
string = B_TRANSLATE("Waiting for media_server to quit.");
|
string = B_TRANSLATE("Telling media_addon_server to quit.");
|
||||||
break;
|
break;
|
||||||
case 50:
|
case 50:
|
||||||
string = B_TRANSLATE("Waiting for media_server to quit.");
|
string = B_TRANSLATE("Waiting for media_addon_server to quit.");
|
||||||
break;
|
break;
|
||||||
case 70:
|
case 70:
|
||||||
string = B_TRANSLATE("Cleaning up.");
|
string = B_TRANSLATE("Cleaning up.");
|
||||||
@ -1299,6 +1299,7 @@ shutdown_media_server(bigtime_t timeout,
|
|||||||
BMessage msg(B_QUIT_REQUESTED);
|
BMessage msg(B_QUIT_REQUESTED);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
status_t err;
|
status_t err;
|
||||||
|
bool shutdown = false;
|
||||||
|
|
||||||
if ((err = msg.AddBool("be:_user_request", true)) != B_OK)
|
if ((err = msg.AddBool("be:_user_request", true)) != B_OK)
|
||||||
return err;
|
return err;
|
||||||
@ -1308,51 +1309,41 @@ shutdown_media_server(bigtime_t timeout,
|
|||||||
progress_shutdown(10, progress, cookie);
|
progress_shutdown(10, progress, cookie);
|
||||||
|
|
||||||
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
|
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
|
||||||
if (err != B_OK)
|
reply.FindBool("_shutdown", &shutdown);
|
||||||
|
if (err == B_TIMED_OUT || shutdown == false) {
|
||||||
|
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE))
|
||||||
|
kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
|
||||||
|
} else if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
int32 rv;
|
|
||||||
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
|
|
||||||
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE);
|
|
||||||
progress_shutdown(20, progress, cookie);
|
progress_shutdown(20, progress, cookie);
|
||||||
|
|
||||||
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
|
|
||||||
if (err != B_OK)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
int32 rv;
|
int32 rv;
|
||||||
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
|
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
|
shutdown = false;
|
||||||
|
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
|
||||||
|
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE);
|
||||||
progress_shutdown(40, progress, cookie);
|
progress_shutdown(40, progress, cookie);
|
||||||
snooze(200000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
|
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
|
||||||
|
reply.FindBool("_shutdown", &shutdown);
|
||||||
|
if (err == B_TIMED_OUT || shutdown == false) {
|
||||||
|
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE))
|
||||||
|
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
|
||||||
|
} else if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
progress_shutdown(50, progress, cookie);
|
progress_shutdown(50, progress, cookie);
|
||||||
snooze(200000);
|
|
||||||
}
|
|
||||||
|
|
||||||
progress_shutdown(70, progress, cookie);
|
int32 rv;
|
||||||
snooze(1000000);
|
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
|
||||||
|
return rv;
|
||||||
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
|
|
||||||
kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
|
|
||||||
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_shutdown(100, progress, cookie);
|
progress_shutdown(100, progress, cookie);
|
||||||
snooze(1000000);
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user