summaryrefslogtreecommitdiff
path: root/nfs
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1996-11-05 02:49:37 +0000
committerThomas Bushnell <thomas@gnu.org>1996-11-05 02:49:37 +0000
commit4eb5aea93d0475ca69c5e4538736dfcdc7810a6c (patch)
tree962ba85b320b6caf4d84ff95ea66da875cdfe483 /nfs
parent2ec3ebf1a5c24c5c4296ebb3d570df6ab86ae855 (diff)
Mon Nov 4 21:23:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* rpc.c (rpc_list_lock): Delete variable. Omit all mention of it throughout this file. Expand the use of outstanding_lock to cover what rpc_list_lock used to handle.
Diffstat (limited to 'nfs')
-rw-r--r--nfs/ChangeLog6
-rw-r--r--nfs/rpc.c35
2 files changed, 19 insertions, 22 deletions
diff --git a/nfs/ChangeLog b/nfs/ChangeLog
index 945a1d61..fb95b7cc 100644
--- a/nfs/ChangeLog
+++ b/nfs/ChangeLog
@@ -1,3 +1,9 @@
+Mon Nov 4 21:23:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * rpc.c (rpc_list_lock): Delete variable. Omit all mention of it
+ throughout this file. Expand the use of outstanding_lock to cover
+ what rpc_list_lock used to handle.
+
Fri Nov 1 18:12:21 1996 Miles Bader <miles@gnu.ai.mit.edu>
* rpc.c (conduct_rpc): Unlock OUTSTANDING_LOCK if write fails.
diff --git a/nfs/rpc.c b/nfs/rpc.c
index cbc5a198..8068e0ff 100644
--- a/nfs/rpc.c
+++ b/nfs/rpc.c
@@ -46,16 +46,11 @@ struct rpc_list
/* A list of all the pending RPCs. */
static struct rpc_list *outstanding_rpcs;
-/* This lock must be held around any modifications to the list
- structure of outstanding_rpcs. */
-static spin_lock_t rpc_list_lock = SPIN_LOCK_INITIALIZER;
-
/* Wake up this condition when an outstanding RPC has received a reply
or we should check for timeouts. */
static struct condition rpc_wakeup = CONDITION_INITIALIZER;
-/* This lock must be held around modifications of the REPLY members of
- records on outstanding_rpcs and around uses of rpc_wakeup. */
+/* Lock the global data and the REPLY fields of outstanding RPC's. */
static struct mutex outstanding_lock = MUTEX_INITIALIZER;
@@ -135,15 +130,14 @@ initialize_rpc (int program, int version, int rpc_proc,
return p;
}
-/* Remove HDR from the list of pending RPC's. */
+/* Remove HDR from the list of pending RPC's. rpc_list_lock must be
+ held */
static void
unlink_rpc (struct rpc_list *hdr)
{
- spin_lock (&rpc_list_lock);
*hdr->prevp = hdr->next;
if (hdr->next)
hdr->next->prevp = hdr->prevp;
- spin_unlock (&rpc_list_lock);
}
/* Send the specified RPC message. *RPCBUF is the initialized buffer
@@ -166,14 +160,14 @@ conduct_rpc (void **rpcbuf, int **pp)
int n;
int cancel;
+ mutex_lock (&outstanding_lock);
+
/* Link it in */
- spin_lock (&rpc_list_lock);
hdr->next = outstanding_rpcs;
if (hdr->next)
hdr->next->prevp = &hdr->next;
hdr->prevp = &outstanding_rpcs;
outstanding_rpcs = hdr;
- spin_unlock (&rpc_list_lock);
xid = * (int *) (*rpcbuf + sizeof (struct rpc_list));
@@ -183,19 +177,19 @@ conduct_rpc (void **rpcbuf, int **pp)
if (mounted_soft && ntransmit == soft_retries)
{
unlink_rpc (hdr);
+ mutex_unlock (&outstanding_lock);
return ETIMEDOUT;
}
/* Issue the RPC */
- mutex_lock (&outstanding_lock);
lasttrans = mapped_time->seconds;
ntransmit++;
nc = (void *) *pp - *rpcbuf - sizeof (struct rpc_list);
cc = write (main_udp_socket, *rpcbuf + sizeof (struct rpc_list), nc);
if (cc == -1)
{
- mutex_unlock (&outstanding_lock);
unlink_rpc (hdr);
+ mutex_unlock (&outstanding_lock);
return errno;
}
else
@@ -207,11 +201,11 @@ conduct_rpc (void **rpcbuf, int **pp)
&& (mapped_time->seconds - lasttrans < timeout)
&& !cancel)
cancel = hurd_condition_wait (&rpc_wakeup, &outstanding_lock);
- mutex_unlock (&outstanding_lock);
if (cancel)
{
unlink_rpc (hdr);
+ mutex_unlock (&outstanding_lock);
return EINTR;
}
@@ -224,6 +218,8 @@ conduct_rpc (void **rpcbuf, int **pp)
}
while (!hdr->reply);
+ mutex_unlock (&outstanding_lock);
+
/* Switch to the reply buffer. */
*rpcbuf = hdr->reply;
free (hdr);
@@ -357,7 +353,7 @@ rpc_receive_thread ()
else
{
xid = *(int *)buf;
- spin_lock (&rpc_list_lock);
+ mutex_lock (&outstanding_lock);
for (r = outstanding_rpcs; r; r = r->next)
{
if (* (int *) &r[1] == xid)
@@ -366,20 +362,15 @@ rpc_receive_thread ()
*r->prevp = r->next;
if (r->next)
r->next->prevp = r->prevp;
- spin_unlock (&rpc_list_lock);
- mutex_lock (&outstanding_lock);
r->reply = buf;
condition_broadcast (&rpc_wakeup);
- mutex_unlock (&outstanding_lock);
break;
}
}
if (!r)
- {
- spin_unlock (&rpc_list_lock);
- fprintf (stderr, "NFS dropping reply xid %d\n", xid);
- }
+ fprintf (stderr, "NFS dropping reply xid %d\n", xid);
+ mutex_unlock (&outstanding_lock);
}
}
while (!r);