From owner-svn-src-projects@FreeBSD.ORG Mon Jun 9 14:24:42 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 852BE376; Mon, 9 Jun 2014 14:24:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 720A029C3; Mon, 9 Jun 2014 14:24:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s59EOgue039697; Mon, 9 Jun 2014 14:24:42 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s59EOg1V039696; Mon, 9 Jun 2014 14:24:42 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201406091424.s59EOg1V039696@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 9 Jun 2014 14:24:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r267271 - projects/sendfile/sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2014 14:24:42 -0000 Author: glebius Date: Mon Jun 9 14:24:41 2014 New Revision: 267271 URL: http://svnweb.freebsd.org/changeset/base/267271 Log: - Relax assertion in sb_shift_nrdy(), there is corner case when it is not held. - Make sbready() capable to work not only on send buffer, but on receive buffers, as well. Caller should lock the buffer and check that it can SEND/RECVMORE. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/sendfile/sys/kern/uipc_sockbuf.c Modified: projects/sendfile/sys/kern/uipc_sockbuf.c ============================================================================== --- projects/sendfile/sys/kern/uipc_sockbuf.c Mon Jun 9 14:18:24 2014 (r267270) +++ projects/sendfile/sys/kern/uipc_sockbuf.c Mon Jun 9 14:24:41 2014 (r267271) @@ -72,7 +72,9 @@ static void sb_shift_nrdy(struct sockbuf *sb, struct mbuf *m) { +#if 0 /* XXX: not yet: soclose() call path comes here w/o lock. */ SOCKBUF_LOCK_ASSERT(sb); +#endif KASSERT(m->m_flags & M_NOTREADY, ("%s: m %p !M_NOTREADY", __func__, m)); m = m->m_next; @@ -90,12 +92,7 @@ sbready(struct sockbuf *sb, struct mbuf { u_int blocker; - SOCKBUF_LOCK(sb); - - if (sb->sb_state & SBS_CANTSENDMORE) { - SOCKBUF_UNLOCK(sb); - return (ENOTCONN); - } + SOCKBUF_LOCK_ASSERT(sb); KASSERT(sb->sb_fnrdy != NULL, ("%s: sb %p NULL fnrdy", __func__, sb)); @@ -109,10 +106,8 @@ sbready(struct sockbuf *sb, struct mbuf sb->sb_acc += m->m_len; } - if (!blocker) { - SOCKBUF_UNLOCK(sb); - return (EWOULDBLOCK); - } + if (!blocker) + return (EINPROGRESS); /* This one was blocking all the queue. */ for (; m && (m->m_flags & M_NOTREADY) == 0; m = m->m_next) { @@ -124,8 +119,6 @@ sbready(struct sockbuf *sb, struct mbuf sb->sb_fnrdy = m; - SOCKBUF_UNLOCK(sb); - return (0); }