Skip to content

Commit

Permalink
tipc: wake up all waiting threads at socket shutdown
Browse files Browse the repository at this point in the history
When a socket is shut down, we should wake up all thread sleeping on
it, instead of just one of them. Otherwise, when several threads are
polling the same socket, and one of them does shutdown(), the
remaining threads may end up sleeping forever.

Also, to align socket usage with common practice in other stacks, we
use one of the common socket callback handlers, sk_state_change(),
to wake up pending users. This is similar to the usage in e.g.
inet_shutdown(). [net/ipv4/af_inet.c].

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
  • Loading branch information
Ying Xue authored and Paul Gortmaker committed Nov 22, 2012
1 parent c4fc298 commit 7503115
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,10 +1595,11 @@ static int shutdown(struct socket *sock, int how)

case SS_DISCONNECTING:

/* Discard any unreceived messages; wake up sleeping tasks */
/* Discard any unreceived messages */
discard_rx_queue(sk);
if (waitqueue_active(sk_sleep(sk)))
wake_up_interruptible(sk_sleep(sk));

/* Wake up anyone sleeping in poll */
sk->sk_state_change(sk);
res = 0;
break;

Expand Down

0 comments on commit 7503115

Please sign in to comment.