Avoid nfsiods acquiring/releasing a lock, then acquiring it again, before
anyone else can get to it, by checking if a reply was received, and it has thus become unnecessary to take the lock. From FreeBSD. XXX I don't really like this, "locks" potentially suffer from the same problem throughout the whole kernel; they should probably be FIFO everywhere.
This commit is contained in:
parent
63d11b7577
commit
b4e49cf0e9
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_socket.c,v 1.35 1997/02/22 02:59:08 fvdl Exp $ */
|
||||
/* $NetBSD: nfs_socket.c,v 1.36 1997/04/08 17:57:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1995
|
||||
@ -637,13 +637,10 @@ nfs_reply(myrep)
|
||||
* race conditions during a reconnect.
|
||||
*/
|
||||
error = nfs_rcvlock(myrep);
|
||||
if (error == EALREADY)
|
||||
return (0);
|
||||
if (error)
|
||||
return (error);
|
||||
/* Already received, bye bye */
|
||||
if (myrep->r_mrep != NULL) {
|
||||
nfs_rcvunlock(&nmp->nm_flag);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Get the next Rpc reply off the socket
|
||||
*/
|
||||
@ -1443,6 +1440,13 @@ nfs_rcvlock(rep)
|
||||
*flagp |= NFSMNT_WANTRCV;
|
||||
(void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk",
|
||||
slptimeo);
|
||||
/* If our reply was received while we were sleeping,
|
||||
* then just return without taking the lock to avoid a
|
||||
* situation where a single iod could 'capture' the
|
||||
* receive lock.
|
||||
*/
|
||||
if (rep->r_mrep != NULL)
|
||||
return (EALREADY);
|
||||
if (slpflag == PCATCH) {
|
||||
slpflag = 0;
|
||||
slptimeo = 2 * hz;
|
||||
|
Loading…
Reference in New Issue
Block a user