Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Aug 2017 20:49:19 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322856 - head/sys/kern
Message-ID:  <201708242049.v7OKnJF4077693@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Thu Aug 24 20:49:19 2017
New Revision: 322856
URL: https://svnweb.freebsd.org/changeset/base/322856

Log:
  Third take on the r319685 and r320480.  Actually allow for call soisconnected()
  via soisdisconnected(), and in the earlier unlock earlier to avoid lock
  recursion.
  
  This fixes a situation when a socket on accept queue is reset before being
  accepted.
  
  Reported by:	Jason Eggleston <jeggleston llnw.com>

Modified:
  head/sys/kern/uipc_sockbuf.c
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_sockbuf.c
==============================================================================
--- head/sys/kern/uipc_sockbuf.c	Thu Aug 24 20:19:27 2017	(r322855)
+++ head/sys/kern/uipc_sockbuf.c	Thu Aug 24 20:49:19 2017	(r322856)
@@ -334,7 +334,7 @@ sowakeup(struct socket *so, struct sockbuf *sb)
 	if (sb->sb_flags & SB_AIO)
 		sowakeup_aio(so, sb);
 	SOCKBUF_UNLOCK(sb);
-	if (ret == SU_ISCONNECTED && !(so->so_state & SS_ISDISCONNECTED))
+	if (ret == SU_ISCONNECTED)
 		soisconnected(so);
 	if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL)
 		pgsigio(&so->so_sigio, SIGIO, 0);

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Thu Aug 24 20:19:27 2017	(r322855)
+++ head/sys/kern/uipc_socket.c	Thu Aug 24 20:49:19 2017	(r322856)
@@ -3769,13 +3769,14 @@ soisdisconnected(struct socket *so)
 	so->so_state |= SS_ISDISCONNECTED;
 
 	if (!SOLISTENING(so)) {
+		SOCK_UNLOCK(so);
 		SOCKBUF_LOCK(&so->so_rcv);
 		socantrcvmore_locked(so);
 		SOCKBUF_LOCK(&so->so_snd);
 		sbdrop_locked(&so->so_snd, sbused(&so->so_snd));
 		socantsendmore_locked(so);
-	}
-	SOCK_UNLOCK(so);
+	} else
+		SOCK_UNLOCK(so);
 	wakeup(&so->so_timeo);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708242049.v7OKnJF4077693>