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

@ -27,7 +27,7 @@ class AsyncInvoker;
// on the calling thread if necessary.
class AsyncClosure {
public:
explicit AsyncClosure(AsyncInvoker* invoker) : invoker_(invoker) {}
explicit AsyncClosure(AsyncInvoker* invoker);
virtual ~AsyncClosure();
// Runs the asynchronous task, and triggers a callback to the calling
// thread if needed. Should be called from the target thread.