Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Feb 2011 21:05:07 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r218456 - stable/7/sys/nfsserver
Message-ID:  <201102082105.p18L579d059798@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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