Skip to content

Commit

Permalink
browser(firefox): reliably close the pipe (#3280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Aug 4, 2020
1 parent 573f580 commit d3a40be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions browser_patches/firefox/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1149
Changed: dgozman@gmail.com Mon Aug 3 15:21:45 PDT 2020
1150
Changed: dgozman@gmail.com Mon Aug 3 19:37:50 PDT 2020
6 changes: 5 additions & 1 deletion browser_patches/firefox/juggler/components/juggler.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ CommandLineHandler.prototype = {
const browserHandler = new BrowserHandler(dispatcher.rootSession(), dispatcher, targetRegistry, () => {
if (silent)
Services.startup.exitLastWindowClosingSurvivalArea();
pipe.stop();
// Send response to the Browser.close, and then stop in the next microtask.
Promise.resolve().then(() => {
connection.onclose();
pipe.stop();
});
});
dispatcher.rootSession().registerHandler('Browser', browserHandler);
loadFrameScript();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ nsresult nsRemoteDebuggingPipe::Stop() {
#if defined(_WIN32)
CancelIoEx(readHandle, nullptr);
CloseHandle(readHandle);
CloseHandle(writeHandle);
#else
shutdown(readFD, SHUT_RDWR);
shutdown(writeFD, SHUT_RDWR);
#endif
mReaderThread->Shutdown();
mReaderThread = nullptr;
mWriterThread->AsyncShutdown();
mWriterThread->Shutdown();
mWriterThread = nullptr;
return NS_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion browser_patches/firefox/juggler/protocol/BrowserHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ class BrowserHandler {
}

async close() {
this._onclose();
let browserWindow = Services.wm.getMostRecentWindow(
"navigator:browser"
);
if (browserWindow && browserWindow.gBrowserInit) {
await browserWindow.gBrowserInit.idleTasksFinishedPromise;
}
this._onclose();
Services.startup.quit(Ci.nsIAppStartup.eForceQuit);
}

Expand Down

0 comments on commit d3a40be

Please sign in to comment.