int tcurlen;
int tnLeft;
char *tcurpos;
+ int locked = 1;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
tnLeft = call->nLeft;
if (!call->error && tcurlen > nbytes && tnLeft > nbytes) {
tcurpos = call->curpos;
- memcpy(buf, tcurpos, nbytes);
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ locked = 0;
+
+ memcpy(buf, tcurpos, nbytes);
+
call->curpos = tcurpos + nbytes;
call->curlen = tcurlen - nbytes;
call->nLeft = tnLeft - nbytes;
if (!call->nLeft && call->currentPacket != NULL) {
/* out of packet. Get another one. */
+ NETPRI;
+ MUTEX_ENTER(&call->lock);
+ locked = 1;
rxi_FreePacket(call->currentPacket);
call->currentPacket = (struct rx_packet *)0;
}
} else
bytes = rxi_ReadProc(call, buf, nbytes);
- MUTEX_EXIT(&call->lock);
- USERPRI;
+ if (locked) {
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ }
return bytes;
}
int tcurlen;
int tnLeft;
char *tcurpos;
+ int locked = 1;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
if (!call->error && tcurlen >= sizeof(afs_int32)
&& tnLeft >= sizeof(afs_int32)) {
tcurpos = call->curpos;
- memcpy((char *)value, tcurpos, sizeof(afs_int32));
- call->curpos = tcurpos + sizeof(afs_int32);
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ locked = 0;
+
+ memcpy((char *)value, tcurpos, sizeof(afs_int32));
+
+ call->curpos = tcurpos + sizeof(afs_int32);
call->curlen = (u_short)(tcurlen - sizeof(afs_int32));
call->nLeft = (u_short)(tnLeft - sizeof(afs_int32));
if (!call->nLeft && call->currentPacket != NULL) {
/* out of packet. Get another one. */
+ NETPRI;
+ MUTEX_ENTER(&call->lock);
+ locked = 1;
rxi_FreePacket(call->currentPacket);
call->currentPacket = (struct rx_packet *)0;
}
} else
bytes = rxi_ReadProc(call, (char *)value, sizeof(afs_int32));
- MUTEX_EXIT(&call->lock);
- USERPRI;
+ if (locked) {
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ }
return bytes;
}
int tcurlen;
int tnFree;
char *tcurpos;
+ int locked = 1;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
tnFree = (int)call->nFree;
if (!call->error && tcurlen >= nbytes && tnFree >= nbytes) {
tcurpos = call->curpos;
+
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ locked = 0;
+
memcpy(tcurpos, buf, nbytes);
call->curpos = tcurpos + nbytes;
call->curlen = (u_short)(tcurlen - nbytes);
} else
bytes = rxi_WriteProc(call, buf, nbytes);
- MUTEX_EXIT(&call->lock);
- USERPRI;
+ if (locked) {
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ }
return bytes;
}
int tcurlen;
int tnFree;
char *tcurpos;
+ int locked = 1;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
if (!call->error && tcurlen >= sizeof(afs_int32)
&& tnFree >= sizeof(afs_int32)) {
tcurpos = call->curpos;
+
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ locked = 0;
+
if (!((size_t)tcurpos & (sizeof(afs_int32) - 1))) {
*((afs_int32 *) (tcurpos)) = *value;
} else {
} else
bytes = rxi_WriteProc(call, (char *)value, sizeof(afs_int32));
- MUTEX_EXIT(&call->lock);
- USERPRI;
+ if (locked) {
+ MUTEX_EXIT(&call->lock);
+ USERPRI;
+ }
return bytes;
}