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);
}
/*
- * 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