svn commit: r334855 - head/sys/kern
Matt Macy
mmacy at FreeBSD.org
Fri Jun 8 20:32:01 UTC 2018
Author: mmacy
Date: Fri Jun 8 20:31:59 2018
New Revision: 334855
URL: https://svnweb.freebsd.org/changeset/base/334855
Log:
AF_UNIX: bring uipc_ready in compliance with new locking protocol
PR: 228742
Submitted by: markj
Reviewed by: markj
Modified:
head/sys/kern/uipc_usrreq.c
Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c Fri Jun 8 19:47:04 2018 (r334854)
+++ head/sys/kern/uipc_usrreq.c Fri Jun 8 20:31:59 2018 (r334855)
@@ -1262,14 +1262,21 @@ uipc_ready(struct socket *so, struct mbuf *m, int coun
unp = sotounpcb(so);
- UNP_LINK_RLOCK();
+ UNP_PCB_LOCK(unp);
if ((unp2 = unp->unp_conn) == NULL) {
- UNP_LINK_RUNLOCK();
- for (int i = 0; i < count; i++)
- m = m_free(m);
- return (ECONNRESET);
+ UNP_PCB_UNLOCK(unp);
+ goto error;
}
- UNP_PCB_LOCK(unp2);
+ if (unp != unp2) {
+ if (UNP_PCB_TRYLOCK(unp2) == 0) {
+ unp_pcb_hold(unp2);
+ UNP_PCB_UNLOCK(unp);
+ UNP_PCB_LOCK(unp2);
+ if (unp_pcb_rele(unp2))
+ goto error;
+ } else
+ UNP_PCB_UNLOCK(unp);
+ }
so2 = unp2->unp_socket;
SOCKBUF_LOCK(&so2->so_rcv);
@@ -1279,9 +1286,12 @@ uipc_ready(struct socket *so, struct mbuf *m, int coun
SOCKBUF_UNLOCK(&so2->so_rcv);
UNP_PCB_UNLOCK(unp2);
- UNP_LINK_RUNLOCK();
return (error);
+ error:
+ for (int i = 0; i < count; i++)
+ m = m_free(m);
+ return (ECONNRESET);
}
static int
More information about the svn-src-all
mailing list