about summary refs log tree commit homepage
path: root/ext/kgio/missing/accept4.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/kgio/missing/accept4.h')
-rw-r--r--ext/kgio/missing/accept4.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/kgio/missing/accept4.h b/ext/kgio/missing/accept4.h
index cd8be79..f2f3ba9 100644
--- a/ext/kgio/missing/accept4.h
+++ b/ext/kgio/missing/accept4.h
@@ -33,8 +33,12 @@ accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
                 if ((flags & SOCK_NONBLOCK) == SOCK_NONBLOCK) {
                         int fl = fcntl(fd, F_GETFL);
 
-                        if ((fl & O_NONBLOCK) == 0)
-                                (void)fcntl(fd, F_SETFL, fl | O_NONBLOCK);
+                        /*
+                         * unconditional, OSX 10.4 (and maybe other *BSDs)
+                         * F_GETFL returns a false O_NONBLOCK with TCP sockets
+                         * (but not UNIX sockets) [ruby-talk:274079]
+                         */
+                        (void)fcntl(fd, F_SETFL, fl | O_NONBLOCK);
                 }
 
                 /*