All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Malat <oss@malat.biz>
To: linux-sctp@vger.kernel.org
Subject: [PATCH] sctp: Wake up all processes after closing the connection
Date: Thu, 02 Jul 2020 08:01:26 +0000	[thread overview]
Message-ID: <20200702080126.8951-1-oss@malat.biz> (raw)

All waiters need to be woken up after a state change to ESTABLISHED,
CLOSED or SHUTDOWN_RECEIVED, as that's the time when they all should
react - for example all threads blocked in send() must return an
error when the connection is closed, not only one of them.

This solves the problem of threads sleeping indefinitely in
sctp_sendmsg_to_asoc() when the connection was closed while multiple
threads were waiting for SNDBUF.

Signed-off-by: Petr Malat <oss@malat.biz>
---
 net/sctp/sm_sideeffect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 9f36fe911d08..ae08b1805b45 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -892,11 +892,11 @@ static void sctp_cmd_new_state(struct sctp_cmd_seq *cmds,
 	if (sctp_state(asoc, ESTABLISHED) ||
 	    sctp_state(asoc, CLOSED) ||
 	    sctp_state(asoc, SHUTDOWN_RECEIVED)) {
-		/* Wake up any processes waiting in the asoc's wait queue in
+		/* Wake up all processes waiting in the asoc's wait queue in
 		 * sctp_wait_for_connect() or sctp_wait_for_sndbuf().
 		 */
 		if (waitqueue_active(&asoc->wait))
-			wake_up_interruptible(&asoc->wait);
+			wake_up_interruptible_all(&asoc->wait);
 
 		/* Wake up any processes waiting in the sk's sleep queue of
 		 * a TCP-style or UDP-style peeled-off socket in
-- 
2.20.1

             reply	other threads:[~2020-07-02  8:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  8:01 Petr Malat [this message]
2020-07-02 12:55 ` [PATCH] sctp: Wake up all processes after closing the connection Marcelo Ricardo Leitner

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=20200702080126.8951-1-oss@malat.biz \
    --to=oss@malat.biz \
    --cc=linux-sctp@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.