X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/cc9f6e38162d3c1bf6ca97536c2477f476c8e01b..378393581903b274cb7a4d18e0d978071a6b592d:/bsd/kern/uipc_socket2.c diff --git a/bsd/kern/uipc_socket2.c b/bsd/kern/uipc_socket2.c index 1d324fc8b..30750607f 100644 --- a/bsd/kern/uipc_socket2.c +++ b/bsd/kern/uipc_socket2.c @@ -142,18 +142,22 @@ soisconnected(so) sflt_notify(so, sock_evt_connected, NULL); if (head && (so->so_state & SS_INCOMP)) { - if (head->so_proto->pr_getlock != NULL) + so->so_state &= ~SS_INCOMP; + so->so_state |= SS_COMP; + if (head->so_proto->pr_getlock != NULL) { + socket_unlock(so, 0); socket_lock(head, 1); + } postevent(head, 0, EV_RCONN); TAILQ_REMOVE(&head->so_incomp, so, so_list); head->so_incqlen--; - so->so_state &= ~SS_INCOMP; TAILQ_INSERT_TAIL(&head->so_comp, so, so_list); - so->so_state |= SS_COMP; sorwakeup(head); wakeup_one((caddr_t)&head->so_timeo); - if (head->so_proto->pr_getlock != NULL) + if (head->so_proto->pr_getlock != NULL) { socket_unlock(head, 1); + socket_lock(so, 0); + } } else { postevent(so, 0, EV_WCONN); wakeup((caddr_t)&so->so_timeo); @@ -291,16 +295,19 @@ sonewconn_internal(head, connstatus) } /* - * Must be done with head unlocked to avoid deadlock with pcb list + * Must be done with head unlocked to avoid deadlock for protocol with per socket mutexes. */ - socket_unlock(head, 0); + if (head->so_proto->pr_unlock) + socket_unlock(head, 0); if (((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL) != 0) || error) { sflt_termsock(so); sodealloc(so); - socket_lock(head, 0); + if (head->so_proto->pr_unlock) + socket_lock(head, 0); return ((struct socket *)0); } - socket_lock(head, 0); + if (head->so_proto->pr_unlock) + socket_lock(head, 0); #ifdef __APPLE__ so->so_proto->pr_domain->dom_refs++; #endif