Page MenuHomeFreeBSD

D26296.id76542.diff
No OneTemporary

D26296.id76542.diff

Index: sys/kern/uipc_usrreq.c
===================================================================
--- sys/kern/uipc_usrreq.c
+++ sys/kern/uipc_usrreq.c
@@ -335,12 +335,14 @@
}
static void
-unp_pcb_lock2(struct unpcb *unp, struct unpcb *unp2)
+unp_pcb_lock_pair(struct unpcb *unp, struct unpcb *unp2)
{
- MPASS(unp != unp2);
UNP_PCB_UNLOCK_ASSERT(unp);
UNP_PCB_UNLOCK_ASSERT(unp2);
- if ((uintptr_t)unp2 > (uintptr_t)unp) {
+
+ if (unp == unp2) {
+ UNP_PCB_LOCK(unp);
+ } else if ((uintptr_t)unp2 > (uintptr_t)unp) {
UNP_PCB_LOCK(unp);
UNP_PCB_LOCK(unp2);
} else {
@@ -738,10 +740,7 @@
KASSERT(unp != NULL, ("uipc_connect2: unp == NULL"));
unp2 = so2->so_pcb;
KASSERT(unp2 != NULL, ("uipc_connect2: unp2 == NULL"));
- if (unp != unp2)
- unp_pcb_lock2(unp, unp2);
- else
- UNP_PCB_LOCK(unp);
+ unp_pcb_lock_pair(unp, unp2);
error = unp_connect2(so1, so2, PRU_CONNECT2);
if (unp != unp2)
UNP_PCB_UNLOCK(unp2);
@@ -1640,7 +1639,7 @@
goto bad2;
}
unp3 = sotounpcb(so2);
- unp_pcb_lock2(unp2, unp3);
+ unp_pcb_lock_pair(unp2, unp3);
if (unp2->unp_addr != NULL) {
bcopy(unp2->unp_addr, sa, unp2->unp_addr->sun_len);
unp3->unp_addr = (struct sockaddr_un *) sa;
@@ -1662,10 +1661,7 @@
mac_socketpeer_set_from_socket(so2, so);
#endif
} else {
- if (unp == unp2)
- UNP_PCB_LOCK(unp);
- else
- unp_pcb_lock2(unp, unp2);
+ unp_pcb_lock_pair(unp, unp2);
}
KASSERT(unp2 != NULL && so2 != NULL && unp2->unp_socket == so2 &&
sotounpcb(so2) == unp2,

File Metadata

Mime Type
text/plain
Expires
Sun, Jun 14, 3:37 PM (55 m, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33955612
Default Alt Text
D26296.id76542.diff (1 KB)

Event Timeline