]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/uipc_usrreq.c
xnu-517.tar.gz
[apple/xnu.git] / bsd / kern / uipc_usrreq.c
index d8022230cdf1696fec6348b3dcd714cf09a1975d..10688922f92a5b7e8d3a2387e6787a626655b618 100644 (file)
@@ -663,6 +663,18 @@ unp_connect(so, nam, p)
                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) {