Commit a5bffff6 authored by Lucas Dobson-Defenbaugh's avatar Lucas Dobson-Defenbaugh Committed by Facebook Github Bot

Check for existence of thread during getEventBase

Summary: During shutdown there's a race condition in IOThreadPoolExecutor::getEventBase where a thread is created in ensureActiveThreads, and then destroyed before pickThread() is called. This adds the same guard that exists in add().

Reviewed By: yfeldblum

Differential Revision: D17955227

fbshipit-source-id: 042cb5c42056a9da4578571fb10936bbc477c4ff
parent fc88fcbf
......@@ -141,6 +141,9 @@ IOThreadPoolExecutor::pickThread() {
EventBase* IOThreadPoolExecutor::getEventBase() {
ensureActiveThreads();
SharedMutex::ReadHolder r{&threadListLock_};
if (threadList_.get().empty()) {
throw std::runtime_error("No threads available");
}
return pickThread()->eventBase;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment