]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/uipc_usrreq.c
xnu-517.9.5.tar.gz
[apple/xnu.git] / bsd / kern / uipc_usrreq.c
index 905652beeb9f7f9373eb03008eea25d9c6767ed5..dda829231628222732dd0398019d98122a122075 100644 (file)
@@ -660,6 +660,18 @@ unp_connect(so, nam, p)
                goto bad;
        }
        thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
                goto bad;
        }
        thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+       
+       /*
+        * Check if socket was connected while we were trying to
+        * acquire the funnel.
+        * XXX - probably shouldn't return an error for SOCK_DGRAM
+        */
+       if ((so->so_state & SS_ISCONNECTED) != 0) {
+               error = EISCONN;
+               thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
+               goto bad;
+       }
+       
        if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
                if ((so2->so_options & SO_ACCEPTCONN) == 0 ||
                    (so3 = sonewconn(so2, 0)) == 0) {
        if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
                if ((so2->so_options & SO_ACCEPTCONN) == 0 ||
                    (so3 = sonewconn(so2, 0)) == 0) {