diff --git a/README.md b/README.md index 06aa76c..a28bbf1 100644 --- a/README.md +++ b/README.md @@ -588,116 +588,36 @@ static int binder_thread_release(struct binder_proc *proc, struct binder_thread These lines have been added to source code: - -
static int binder_thread_release(struct binder_proc *proc,
-
-
-
-
-
-
- |
-
* from any epoll data structures holding it with POLLFREE.
- |
-
* waitqueue_active() is safe to use here because we're holding
- |
-
* the inner lock.
- |
-
*/
- |
-
if ((thread->looper & BINDER_LOOPER_STATE_POLL) &&
- |
-
waitqueue_active(&thread->wait)) {
- |
-
wake_up_poll(&thread->wait, EPOLLHUP | POLLFREE);
- |
-
}
- |
-
- | -
binder_inner_proc_unlock(thread->proc);
- |
-
- | -
/*
- |
-
* This is needed to avoid races between wake_up_poll() above and
- |
-
* and ep_remove_waitqueue() called for other reasons (eg the epoll file
- |
-
* descriptor being closed); ep_remove_waitqueue() holds an RCU read
- |
-
* lock, so we can be sure it's done after calling synchronize_rcu().
- |
-
*/
- |
-
if (thread->looper & BINDER_LOOPER_STATE_POLL)
- |
-
- synchronize_rcu();
-
- .
-
-
-
-
-
-
- |
-
+static int binder_thread_release(struct binder_proc *proc, +binder_thread *thread) +{ + . + . + . + /* + * If this thread used poll, make sure we remove the waitqueue + * from any epoll data structures holding it with POLLFREE. + * waitqueue_active() is safe to use here because we're holding + * the inner lock. + */ + if ((thread->looper & BINDER_LOOPER_STATE_POLL) && waitqueue_active(&thread->wait)) { + wake_up_poll(&thread->wait, EPOLLHUP | POLLFREE); + } + binder_inner_proc_unlock(thread->proc); + /* + * This is needed to avoid races between wake_up_poll() above and + * and ep_remove_waitqueue() called for other reasons (eg the epoll file + * descriptor being closed); ep_remove_waitqueue() holds an RCU read + * lock, so we can be sure it's done after calling synchronize_rcu(). + */ + if (thread->looper & BINDER_LOOPER_STATE_POLL) + synchronize_rcu(); + . + . + . +} + see full code [here](https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread_release)