Fixing potential AsyncInvoker deadlock that occurs for "reentrant" invocations.

The deadlock occurs if the AsyncInvoker is destroyed on thread A while
a task on thread B is running, which AsyncInvokes a task back on thread
A.

This was causing pending_invocations_ to end up negative, because
an AsyncClosure that's never added to a thread's message queue (due to
the "destroying_" flag) caused the count to be decremented but not
incremented.

BUG=None

Review-Url: https://codereview.webrtc.org/2885143006
Cr-Commit-Position: refs/heads/master@{#18225}
This commit is contained in:
deadbeef
2017-05-22 15:32:51 -07:00
committed by Commit bot
parent f472699bbd
commit ef37ca5fb3
4 changed files with 51 additions and 23 deletions

View File

@ -120,7 +120,7 @@ class AsyncInvoker : public MessageHandler {
uint32_t id);
volatile int pending_invocations_ = 0;
Event invocation_complete_;
bool destroying_ = false;
int destroying_ = 0;
friend class AsyncClosure;
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncInvoker);