netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, Ying Xue <ying.xue@windriver.com>,
	Jon Maloy <jon.maloy@ericsson.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [PATCH net-next 3/9] tipc: wake up all waiting threads at socket shutdown
Date: Thu, 22 Nov 2012 15:59:48 -0500	[thread overview]
Message-ID: <1353617994-3962-4-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <1353617994-3962-1-git-send-email-paul.gortmaker@windriver.com>

From: Ying Xue <ying.xue@windriver.com>

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>
---
 net/tipc/socket.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 59adc76..1a720c8 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1595,10 +1595,11 @@ restart:
 
 	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;
 
-- 
1.7.12.1

  parent reply	other threads:[~2012-11-22 21:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 20:59 [PATCH net-next 0/9] tipc: updates for what will be v3.8 Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 1/9] tipc: fix race/inefficiencies in poll/wait behaviour Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 2/9] tipc: return POLLOUT for sockets in an unconnected state Paul Gortmaker
2012-11-22 20:59 ` Paul Gortmaker [this message]
2012-11-22 20:59 ` [PATCH net-next 4/9] tipc: remove the bearer congestion mechanism Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 5/9] tipc: remove supportable flag from bclink structure Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 6/9] tipc: rename supported flag to recv_permitted Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 7/9] tipc: introduce message to synchronize broadcast link Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 8/9] tipc: eliminate an unnecessary cast of node variable Paul Gortmaker
2012-11-22 20:59 ` [PATCH net-next 9/9] tipc: delete TIPC_ADVANCED Kconfig variable Paul Gortmaker
2012-11-23 19:10 ` [PATCH net-next 0/9] tipc: updates for what will be v3.8 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353617994-3962-4-git-send-email-paul.gortmaker@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=davem@davemloft.net \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).