Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jun 2011 20:34:41 +0000 (UTC)
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r223119 - stable/8/sys/kern
Message-ID:  <201106152034.p5FKYfFR097295@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trociny
Date: Wed Jun 15 20:34:40 2011
New Revision: 223119
URL: http://svn.freebsd.org/changeset/base/223119

Log:
  MFC r222454:
  
  In soreceive_generic(), if MSG_WAITALL is set but the request is
  larger than the receive buffer, we have to receive in sections.
  When notifying the protocol that some data has been drained the
  lock is released for a moment. Returning we block waiting for the
  rest of data. There is a race, when data could arrive while the
  lock was released and then the connection stalls in sbwait.
  
  Fix this by checking for data before blocking and skip blocking
  if there are some.
  
  PR:		kern/154504
  Reported by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
  Tested by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
  Reviewed by:	rwatson
  
  Approved by:	pjd (mentor)

Modified:
  stable/8/sys/kern/uipc_socket.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/uipc_socket.c
==============================================================================
--- stable/8/sys/kern/uipc_socket.c	Wed Jun 15 19:53:08 2011	(r223118)
+++ stable/8/sys/kern/uipc_socket.c	Wed Jun 15 20:34:40 2011	(r223119)
@@ -1836,10 +1836,16 @@ dontblock:
 			}
 			SBLASTRECORDCHK(&so->so_rcv);
 			SBLASTMBUFCHK(&so->so_rcv);
-			error = sbwait(&so->so_rcv);
-			if (error) {
-				SOCKBUF_UNLOCK(&so->so_rcv);
-				goto release;
+			/*
+			 * We could receive some data while was notifying
+			 * the protocol. Skip blocking in this case.
+			 */
+			if (so->so_rcv.sb_mb == NULL) {
+				error = sbwait(&so->so_rcv);
+				if (error) {
+					SOCKBUF_UNLOCK(&so->so_rcv);
+					goto release;
+				}
 			}
 			m = so->so_rcv.sb_mb;
 			if (m != NULL)



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