diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 23:21:58 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 23:21:58 +0000 |
commit | 485c9bdda68c31147de3ceaf2996c51020a8f3bd (patch) | |
tree | 62489c89c10d207cedf43a0865f8baab8b589cf8 | |
parent | 0aa4563e3258fe6c7d3d292a1c3d48267c9e342d (diff) | |
download | chromium_src-485c9bdda68c31147de3ceaf2996c51020a8f3bd.zip chromium_src-485c9bdda68c31147de3ceaf2996c51020a8f3bd.tar.gz chromium_src-485c9bdda68c31147de3ceaf2996c51020a8f3bd.tar.bz2 |
If background thread gets XIOError, don't call shutdown
BUG=82194
TEST=None
Review URL: http://codereview.chromium.org/7015013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85072 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_main_gtk.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/browser_main_gtk.cc b/chrome/browser/browser_main_gtk.cc index 57b07d1..3701a57 100644 --- a/chrome/browser/browser_main_gtk.cc +++ b/chrome/browser/browser_main_gtk.cc @@ -39,6 +39,10 @@ namespace { // Indicates that we're currently responding to an IO error (by shutting down). bool g_in_x11_io_error_handler = false; +// Number of seconds to wait for UI thread to get an IO error if we get it on +// the background thread. +const int kWaitForUIThreadSeconds = 10; + int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) { if (!g_in_x11_io_error_handler) MessageLoop::current()->PostTask( @@ -47,7 +51,24 @@ int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) { return 0; } + +// This function is used to help us diagnose crash dumps that happen +// during the shutdown process. +NOINLINE void WaitingForUIThreadToHandleIOError() { + // Ensure function isn't optimized away. + asm(""); + sleep(kWaitForUIThreadSeconds); +} + int BrowserX11IOErrorHandler(Display* d) { + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { + // Wait for the UI thread (which has a different connection to the X server) + // to get the error. We can't call shutdown from this thread without + // tripping an error. Doing it through a function so that we'll be able + // to see it in any crash dumps. + WaitingForUIThreadToHandleIOError(); + return 0; + } // If there's an IO error it likely means the X server has gone away if (!g_in_x11_io_error_handler) { g_in_x11_io_error_handler = true; |