fix: ensure utilityProcess
only emits one 'exit' event (#44243)
fix: ensure utilityProcess only emits one exit
This commit is contained in:
parent
b5acebf3ba
commit
df45474b58
3 changed files with 21 additions and 11 deletions
|
@ -247,12 +247,16 @@ void UtilityProcessWrapper::OnServiceProcessLaunch(
|
|||
}
|
||||
|
||||
void UtilityProcessWrapper::HandleTermination(uint64_t exit_code) {
|
||||
// HandleTermination is called from multiple callsites,
|
||||
// we need to ensure we only process it for the first callsite.
|
||||
if (terminated_)
|
||||
return;
|
||||
terminated_ = true;
|
||||
|
||||
if (pid_ != base::kNullProcessId)
|
||||
GetAllUtilityProcessWrappers().Remove(pid_);
|
||||
CloseConnectorPort();
|
||||
|
||||
EmitWithoutEvent("exit", exit_code);
|
||||
|
||||
Unpin();
|
||||
}
|
||||
|
||||
|
@ -292,13 +296,8 @@ void UtilityProcessWrapper::CloseConnectorPort() {
|
|||
}
|
||||
|
||||
void UtilityProcessWrapper::Shutdown(uint64_t exit_code) {
|
||||
if (pid_ != base::kNullProcessId)
|
||||
GetAllUtilityProcessWrappers().Remove(pid_);
|
||||
node_service_remote_.reset();
|
||||
CloseConnectorPort();
|
||||
// Emit 'exit' event
|
||||
EmitWithoutEvent("exit", exit_code);
|
||||
Unpin();
|
||||
HandleTermination(exit_code);
|
||||
}
|
||||
|
||||
void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue