diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 19:48:20 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 19:48:20 +0000 |
commit | ca002f150b3bf2ad55113ac1d093630aa79025d8 (patch) | |
tree | 36b7df88348078f6fe84d0eb1f9a674ffa3b7144 /content/browser/browser_thread.cc | |
parent | a12f43f67b331ce251dc265dbfbf624e68d0863d (diff) | |
download | chromium_src-ca002f150b3bf2ad55113ac1d093630aa79025d8.zip chromium_src-ca002f150b3bf2ad55113ac1d093630aa79025d8.tar.gz chromium_src-ca002f150b3bf2ad55113ac1d093630aa79025d8.tar.bz2 |
Avoid holding a lock during destructor call when not needed
I noticed this while reviewing related code. I don't
know of an actual bug, but it is bad form to hold a
lock when calling a function (destructor) unless
necessary. For example, if the destructor posted
a message, it might cause a hang on linux as the
posting could re-enter this helper. It is also
possible that the task deletion will take an
extended period of time, and that can block
other concurrent posts from taking place.
r=darin
Review URL: http://codereview.chromium.org/6602024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76774 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_thread.cc')
-rw-r--r-- | content/browser/browser_thread.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/content/browser/browser_thread.cc b/content/browser/browser_thread.cc index c0e4355..c128da2 100644 --- a/content/browser/browser_thread.cc +++ b/content/browser/browser_thread.cc @@ -222,12 +222,13 @@ bool BrowserThread::PostTaskHelper( } else { message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); } - } else { - delete task; } if (!guaranteed_to_outlive_target_thread) lock_.Release(); + if (!message_loop) + delete task; + return !!message_loop; } |