From owner-svn-src-stable@FreeBSD.ORG Sun Oct 12 18:49:07 2008 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9059106568A; Sun, 12 Oct 2008 18:49:07 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9671E8FC19; Sun, 12 Oct 2008 18:49:07 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9CIn7Y0052646; Sun, 12 Oct 2008 18:49:07 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9CIn7eX052645; Sun, 12 Oct 2008 18:49:07 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810121849.m9CIn7eX052645@svn.freebsd.org> From: Robert Watson Date: Sun, 12 Oct 2008 18:49:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183804 - in stable/7/sys: . kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Oct 2008 18:49:07 -0000 Author: rwatson Date: Sun Oct 12 18:49:07 2008 New Revision: 183804 URL: http://svn.freebsd.org/changeset/base/183804 Log: Merge r183661 from head to stable/7: Lock receive socket buffer in soo_stat() rather than commenting that we should lock it, which may marginally improve the consistency of the results. Remove comment. Approved by: re (gnn) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/sys_socket.c Modified: stable/7/sys/kern/sys_socket.c ============================================================================== --- stable/7/sys/kern/sys_socket.c Sun Oct 12 12:08:09 2008 (r183803) +++ stable/7/sys/kern/sys_socket.c Sun Oct 12 18:49:07 2008 (r183804) @@ -237,17 +237,16 @@ soo_stat(struct file *fp, struct stat *u /* * If SBS_CANTRCVMORE is set, but there's still data left in the * receive buffer, the socket is still readable. - * - * XXXRW: perhaps should lock socket buffer so st_size result is - * consistent. */ - /* Unlocked read. */ + SOCKBUF_LOCK(&so->so_rcv); if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) == 0 || so->so_rcv.sb_cc != 0) ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH; + ub->st_size = so->so_rcv.sb_cc - so->so_rcv.sb_ctl; + SOCKBUF_UNLOCK(&so->so_rcv); + /* Unlocked read. */ if ((so->so_snd.sb_state & SBS_CANTSENDMORE) == 0) ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; - ub->st_size = so->so_rcv.sb_cc - so->so_rcv.sb_ctl; ub->st_uid = so->so_cred->cr_uid; ub->st_gid = so->so_cred->cr_gid; return (*so->so_proto->pr_usrreqs->pru_sense)(so, ub);