Commits

Anonymous committed 15add66

Added a special case for Mac OS X to work around a bug in Apple's network
stack that errors in connect(2) on a non-blocking socket do not get in the
errno system variable. You have to get them out of the socket with the
SO_ERROR socket option.

Comments (0)

Files changed (1)

     
     enter_blocking_section();
     result = connect(sockPtr->s_fd, &sxPtr->sx_sockaddr, sxPtr->sx_socklen);
+
     error = errno;
+
+#ifdef __APPLE__
+    /* Mac OS X does not return the error in errno on non-blocking sockets */
+    if (result && error == EINVAL) {
+        int optlen = sizeof error;
+        getsockopt(sockPtr->s_fd, SOL_SOCKET, SO_ERROR, &error, &optlen);
+    }
+#endif
+
     leave_blocking_section();
     
     if (result) unix_error(error, "connect", Nothing);