Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zahrayousefijamarani authored Jun 11, 2020
1 parent 66dfae7 commit f7ad229
Showing 1 changed file with 30 additions and 110 deletions.
140 changes: 30 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,116 +588,36 @@ static int binder_thread_release(struct binder_proc *proc, struct binder_thread

These lines have been added to source code:


<table>
<tr>
<td><code>static int binder_thread_release(struct binder_proc *proc,</code>
<p>
<code> struct<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread"> binder_thread</a> *thread)</code>
<code>{</code>
<p>
<code> .</code>
<p>
<code> .</code>
<p>
<code> .</code>
<p>
<code> /* </code>
<p>
<code> * If this thread used poll, make sure we remove the waitqueue</code>
</td>
</tr>
<tr>
<td><code> * from any epoll data structures holding it with POLLFREE.</code>
</td>
</tr>
<tr>
<td><code> * waitqueue_active() is safe to use here because we're holding</code>
</td>
</tr>
<tr>
<td><code> * the inner lock.</code>
</td>
</tr>
<tr>
<td><code> */</code>
</td>
</tr>
<tr>
<td><code> if ((<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#1042thread">thread</a>-><a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread::looper">looper</a> &<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#BINDER_LOOPER_STATE_POLL"> BINDER_LOOPER_STATE_POLL</a>) &&</code>
</td>
</tr>
<tr>
<td><code> <a href="https://code.woboq.org/linux/linux/include/linux/wait.h.html#waitqueue_active"> waitqueue_active</a>(&<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#1042thread">thread</a>-><a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread::wait">wait</a>)) {</code>
</td>
</tr>
<tr>
<td><code><b> <a href="https://code.woboq.org/linux/linux/include/linux/wait.h.html#211">wake_up_poll</a>(&<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#1042thread">thread</a>-><a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread::wait">wait</a>,<a href="https://code.woboq.org/linux/linux/include/uapi/linux/eventpoll.h.html#35"> EPOLLHUP</a> |<a href="https://code.woboq.org/linux/linux/include/uapi/asm-generic/poll.h.html#32"> POLLFREE</a>);</b></code>
</td>
</tr>
<tr>
<td><code> }</code>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td><code> <a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#706">binder_inner_proc_unlock</a>(<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#1042thread">thread</a>-><a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread::proc">proc</a>);</code>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td><code> /*</code>
</td>
</tr>
<tr>
<td><code> * This is needed to avoid races between wake_up_poll() above and</code>
</td>
</tr>
<tr>
<td><code> * and ep_remove_waitqueue() called for other reasons (eg the epoll file</code>
</td>
</tr>
<tr>
<td><code> * descriptor being closed); ep_remove_waitqueue() holds an RCU read</code>
</td>
</tr>
<tr>
<td><code> * lock, so we can be sure it's done after calling synchronize_rcu().</code>
</td>
</tr>
<tr>
<td><code> */</code>
</td>
</tr>
<tr>
<td><code> if (<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#1042thread">thread</a>-><a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#binder_thread::looper">looper</a> &<a href="https://code.woboq.org/linux/linux/drivers/android/binder.c.html#BINDER_LOOPER_STATE_POLL"> BINDER_LOOPER_STATE_POLL</a>)</code>
</td>
</tr>
<tr>
<td>
<code> <a href="https://code.woboq.org/linux/linux/kernel/rcu/tree.c.html#synchronize_rcu">synchronize_rcu</a>();</code>

<code> .</code>
<p>

<code> .</code>
<p>

<code> .</code>
<p>

<code>}</code>
</td>
</tr>
</table>


<pre>
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)


Expand Down

0 comments on commit f7ad229

Please sign in to comment.