diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-05-13 17:47:43 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-05-13 17:47:43 +0000 |
commit | d222a43d256da04a7dbe0a08d82ffbcfe7f17893 (patch) | |
tree | 6beafc9f2129cf38cf08c47190eb0e3f0d91d8b5 /sys/nfs | |
parent | 058c9ffd814b7610bedd175a46763ef16917794e (diff) |
don't grab the receive lock in nfs_rcvlock if the reply has
already been received while we slept. prevents processes from
monopolising the lock.
From FreeBSD;
ok blambert@
tested by johan@ and a few others
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_socket.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 7ea2ec2b45b..dc1d0d0441c 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.57 2008/01/06 17:38:23 blambert Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.58 2008/05/13 17:47:42 thib Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -681,12 +681,8 @@ nfs_reply(myrep) */ error = nfs_rcvlock(myrep); if (error) - return (error); - /* Already received, bye bye */ - if (myrep->r_mrep != NULL) { - nfs_rcvunlock(&nmp->nm_flag); - return (0); - } + return (error == EALREADY ? 0 : error); + /* * Get the next Rpc reply off the socket */ @@ -1381,6 +1377,13 @@ nfs_rcvlock(rep) *flagp |= NFSMNT_WANTRCV; (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk", slptimeo); + if (rep->r_mrep != NULL) { + /* + * Don't take the lock if our reply has been received + * while we where sleeping. + */ + return (EALREADY); + } if (slpflag == PCATCH) { slpflag = 0; slptimeo = 2 * hz; |