From owner-svn-src-all@FreeBSD.ORG Tue Feb 8 21:05:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 384591065693; Tue, 8 Feb 2011 21:05:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 25E3A8FC20; Tue, 8 Feb 2011 21:05:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p18L57JS059800; Tue, 8 Feb 2011 21:05:07 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p18L579d059798; Tue, 8 Feb 2011 21:05:07 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201102082105.p18L579d059798@svn.freebsd.org> From: John Baldwin Date: Tue, 8 Feb 2011 21:05: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: r218456 - stable/7/sys/nfsserver X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2011 21:05:08 -0000 Author: jhb Date: Tue Feb 8 21:05:07 2011 New Revision: 218456 URL: http://svn.freebsd.org/changeset/base/218456 Log: Properly close a socket for a TCP NFS client if the NFS server notices that the client has disconnected while attempting to fetch a request. This accidentally works most of the time because the socket upcall is invoked twice for some reason causing two nfsd threads to be assigned to the same connection. The first thread notices the disconnect when soreceive() fails, and the second thread will then cleanup the connection. Occasionally the second thread will grab the NFSD lock before the first thread has returned from soreceive() to mark the connection as disconnected. When that happens, the socket is never cleaned up and is leaked. Fix this by checking for the disconnect flag if there is an error pulling a request from the connection and closing the socket if it nfsrv_rcv() marked the connection as disconnected. Now the first thread will close the socket in most cases and the socket is never leaked. This is a direct commit to 7 as it is specific to the pre-krpc code used in 7. Modified: stable/7/sys/nfsserver/nfs_syscalls.c Modified: stable/7/sys/nfsserver/nfs_syscalls.c ============================================================================== --- stable/7/sys/nfsserver/nfs_syscalls.c Tue Feb 8 20:39:03 2011 (r218455) +++ stable/7/sys/nfsserver/nfs_syscalls.c Tue Feb 8 21:05:07 2011 (r218456) @@ -366,6 +366,8 @@ nfssvc_nfsd(struct thread *td) slp = nfsd->nfsd_slp; } if (error || (slp->ns_flag & SLP_VALID) == 0) { + if (slp->ns_flag & SLP_DISCONN) + nfsrv_zapsock(slp); if (nd) { if (nd->nd_cr != NULL) crfree(nd->nd_cr);