From: ratchov Date: Fri, 12 Jan 2024 08:47:46 +0000 (+0000) Subject: nfssvc: When the client disconnects, close the socket before sleeping. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=58a5214281b71038e0ae830fcddecf76e884cc3d;p=openbsd nfssvc: When the client disconnects, close the socket before sleeping. If the server doesn't close the socket immediately and starts waiting for the client to reconnect, then the TCP connection will remain open. The client will have to wait for the connection to be closed in order to reconnect with the same source port; this never happens, resulting in a freeze until the file system is umounted. This change fixes Linux NFS clients freezing after 5 min of inactivity. ok miod, help from claudio --- diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 45ff763af20..b19bc3653b3 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_syscalls.c,v 1.119 2023/08/03 09:49:09 mvs Exp $ */ +/* $OpenBSD: nfs_syscalls.c,v 1.120 2024/01/12 08:47:46 ratchov Exp $ */ /* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */ /* @@ -331,14 +331,15 @@ loop: slp = nfsd->nfsd_slp; if (ISSET(slp->ns_flag, SLP_VALID)) { - if (ISSET(slp->ns_flag, SLP_DISCONN)) { - nfsrv_zapsock(slp); - } else if (ISSET(slp->ns_flag, SLP_NEEDQ)) { + if ((slp->ns_flag & (SLP_DISCONN | SLP_NEEDQ)) == + SLP_NEEDQ) { CLR(slp->ns_flag, SLP_NEEDQ); nfs_sndlock(&slp->ns_solock, NULL); nfsrv_rcv(slp->ns_so, (caddr_t)slp, M_WAIT); nfs_sndunlock(&slp->ns_solock); } + if (ISSET(slp->ns_flag, SLP_DISCONN)) + nfsrv_zapsock(slp); error = nfsrv_dorec(slp, nfsd, &nd); SET(nfsd->nfsd_flag, NFSD_REQINPROG);