about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e+07380@yhbt.net>2010-10-06 14:08:35 -0700
committerEric Wong <e@yhbt.net>2010-10-06 14:12:21 -0700
commit637317eb479525dca543eda7a8977410bc43b832 (patch)
tree2a907921923eeed9e69386bb2931c8e48c5594fd
parentca76c75f8a24d0cd6828fe16ca3790a277b35f8d (diff)
downloadkgio-637317eb479525dca543eda7a8977410bc43b832.tar.gz
Apparently fcntl(fd, F_GETFL) can return falsely return the
O_NONBLOCK flag without actually having it set in the kernel.
This is totally broken on the part of the OS.
-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);
                 }
 
                 /*