diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:50:54 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:50:54 +0000 |
commit | 6b213e6150c41a5ad958226dad42259fc4097b35 (patch) | |
tree | 932f364ed12a38c4d4d2b36c168c8b37ab68b3ff /base | |
parent | 88908d6c5279e50382f835ffa159025025d7bc52 (diff) | |
download | chromium_src-6b213e6150c41a5ad958226dad42259fc4097b35.zip chromium_src-6b213e6150c41a5ad958226dad42259fc4097b35.tar.gz chromium_src-6b213e6150c41a5ad958226dad42259fc4097b35.tar.bz2 |
Throw something at the wall. See what sticks.
This is an attempt to fix or defer WorkerPoolMac pool stoppage.
1. Catch Objective-C exceptions thrown in task bodies.
2. Make sure the queue isn't suspended when posting tasks.
BUG=20471
TEST=none
Review URL: http://codereview.chromium.org/1699029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/singleton_objc.h | 2 | ||||
-rw-r--r-- | base/worker_pool_mac.mm | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/base/singleton_objc.h b/base/singleton_objc.h index ba9fc78..3ba5f1e 100644 --- a/base/singleton_objc.h +++ b/base/singleton_objc.h @@ -23,7 +23,7 @@ // static Foo* New() { // return [[Foo alloc] initWithName:@"selecty"]; // } -// } +// }; // ... // Foo* widgetSingleton = SingletonObjC<Foo, FooSingletonTraits>::get(); diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index 35d1079..9a9076e 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -11,6 +11,15 @@ #import "base/singleton_objc.h" #include "base/task.h" +// When C++ exceptions are disabled, the C++ library defines |try| and +// |catch| so as to allow exception-expecting C++ code to build properly when +// language support for exceptions is not present. These macros interfere +// with the use of |@try| and |@catch| in Objective-C files such as this one. +// Undefine these macros here, after everything has been #included, since +// there will be no C++ uses and only Objective-C uses from this point on. +#undef try +#undef catch + namespace { Lock lock_; @@ -75,7 +84,15 @@ size_t outstanding_ = 0; // Operations posted but not completed. base::ScopedNSAutoreleasePool autoreleasePool; - task_->Run(); + @try { + task_->Run(); + } @catch(NSException* exception) { + LOG(ERROR) << "-[TaskOperation main] caught an NSException: " + << [[exception description] UTF8String]; + } @catch(id exception) { + LOG(ERROR) << "-[TaskOperation main] caught an unknown exception"; + } + task_.reset(NULL); { @@ -111,6 +128,15 @@ bool WorkerPool::PostTask(const tracked_objects::Location& from_here, NSOperationQueue* operation_queue = [WorkerPoolObjC sharedOperationQueue]; [operation_queue addOperation:[TaskOperation taskOperationWithTask:task]]; + if ([operation_queue isSuspended]) { + LOG(WARNING) << "WorkerPool::PostTask freeing stuck NSOperationQueue"; + + // Nothing should ever be suspending this queue, but in case it winds up + // happening, free things up. This is a purely speculative shot in the + // dark for http://crbug.com/20471. + [operation_queue setSuspended:NO]; + } + // Periodically calculate the set of operations which have not made // progress and report how many there are. This should provide a // sense of how many clients are seeing hung operations of any sort, |