Bug 1542581 - Block child process termination until the handler is fully initialized r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D27231

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gabriele Svelto 2019-04-17 18:55:14 +00:00
Родитель 3b2a6e156c
Коммит f8519d8324
1 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -783,22 +783,23 @@ bool CrashGenerationServer::AddClient(ClientInfo* client_info) {
client_info->set_dump_request_wait_handle(request_wait_handle);
// OnClientEnd will be called when the client process terminates.
HANDLE process_wait_handle = NULL;
if (!RegisterWaitForSingleObject(&process_wait_handle,
client_info->process_handle(),
OnClientEnd,
client_info,
INFINITE,
WT_EXECUTEONLYONCE)) {
return false;
}
client_info->set_process_exit_wait_handle(process_wait_handle);
// New scope to hold the lock for the shortest time.
{
AutoCriticalSection lock(&sync_);
// OnClientEnd will be called when the client process terminates.
HANDLE process_wait_handle = NULL;
if (!RegisterWaitForSingleObject(&process_wait_handle,
client_info->process_handle(),
OnClientEnd,
client_info,
INFINITE,
WT_EXECUTEONLYONCE)) {
return false;
}
client_info->set_process_exit_wait_handle(process_wait_handle);
if (shutting_down_) {
// If server is shutting down, don't add new clients
return false;
@ -867,6 +868,8 @@ void CrashGenerationServer::HandleClientProcessExit(ClientInfo* client_info) {
clients_.remove(client_info);
}
AutoCriticalSection lock(&sync_);
// Explicitly unregister the process exit wait using the non-blocking method.
// Otherwise, the destructor will attempt to unregister it using the blocking
// method which will lead to a deadlock because it is being called from the