Acquire socket receive buffer mutex before appending and then waking up

a receive socket in DDP.  This reduces the number of mutex operations
required to deliver to a socket by two, and is the model used in other
protocols.
This commit is contained in:
rwatson 2004-12-05 13:27:30 +00:00
parent cf8726aa55
commit c39858036f

View File

@ -421,8 +421,10 @@ ddp_input(m, ifp, elh, phase)
/* /*
* If we found one, deliver th epacket to the socket * If we found one, deliver th epacket to the socket
*/ */
if (sbappendaddr(&ddp->ddp_socket->so_rcv, (struct sockaddr *)&from, SOCKBUF_LOCK(&ddp->ddp_socket->so_rcv);
if (sbappendaddr_locked(&ddp->ddp_socket->so_rcv, (struct sockaddr *)&from,
m, NULL) == 0) { m, NULL) == 0) {
SOCKBUF_UNLOCK(&ddp->ddp_socket->so_rcv);
/* /*
* If the socket is full (or similar error) dump the packet. * If the socket is full (or similar error) dump the packet.
*/ */
@ -432,7 +434,7 @@ ddp_input(m, ifp, elh, phase)
/* /*
* And wake up whatever might be waiting for it * And wake up whatever might be waiting for it
*/ */
sorwakeup(ddp->ddp_socket); sorwakeup_locked(ddp->ddp_socket);
m = NULL; m = NULL;
out: out:
DDP_LIST_SUNLOCK(); DDP_LIST_SUNLOCK();