Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jul 2013 14:21:22 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r252887 - stable/9/sys/kern
Message-ID:  <201307061421.r66ELMAw090108@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Jul  6 14:21:22 2013
New Revision: 252887
URL: http://svnweb.freebsd.org/changeset/base/252887

Log:
  MFC r250102: socket: Make shutdown() wake up a blocked accept().
  
  A blocking accept (and some other operations) waits on &so->so_timeo. Once
  it wakes up, it will detect the SBS_CANTRCVMORE bit.
  
  The error from accept() is [ECONNABORTED] which is not the nicest one -- the
  thread calling accept() needs to know out-of-band what is happening.
  
  A spurious wakeup on so->so_timeo appears harmless (sleep retried) except
  when lingering on close (SO_LINGER, and in that case there is no descriptor
  to call shutdown() on) so this should be fairly safe.
  
  A shutdown() already woke up a blocked accept() for TCP sockets, but not for
  Unix domain sockets. This fix is generic for all domains.
  
  This patch was sent to -hackers@ and -net@ on April 5.

Modified:
  stable/9/sys/kern/uipc_socket.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/uipc_socket.c
==============================================================================
--- stable/9/sys/kern/uipc_socket.c	Sat Jul  6 12:56:30 2013	(r252886)
+++ stable/9/sys/kern/uipc_socket.c	Sat Jul  6 14:21:22 2013	(r252887)
@@ -2339,9 +2339,11 @@ soshutdown(struct socket *so, int how)
 		sorflush(so);
 	if (how != SHUT_RD) {
 		error = (*pr->pr_usrreqs->pru_shutdown)(so);
+		wakeup(&so->so_timeo);
 		CURVNET_RESTORE();
 		return (error);
 	}
+	wakeup(&so->so_timeo);
 	CURVNET_RESTORE();
 	return (0);
 }



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