about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-15 13:18:32 -0800
committerEric Wong <normalperson@yhbt.net>2011-11-15 13:18:32 -0800
commit246cfe96f12ce06a5b504873789ada2efd288885 (patch)
tree02f9a8ed05e8bf2eac3b623160fd6b2dce54fc5a
parent4cef568a9d06033c295c1f4920918c6fed36a24d (diff)
downloadkgio-246cfe96f12ce06a5b504873789ada2efd288885.tar.gz
This is mostly an implementation detail, but it's already
true on OpenBSD (and maybe other BSDs), and also requires
no additional syscalls on newer Linux systems.
-rw-r--r--ext/kgio/accept.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/kgio/accept.c b/ext/kgio/accept.c
index 1dc0d17..661e02c 100644
--- a/ext/kgio/accept.c
+++ b/ext/kgio/accept.c
@@ -10,7 +10,7 @@ static VALUE cKgio_Socket;
 static VALUE mSocketMethods;
 static VALUE iv_kgio_addr;
 
-#if defined(__linux__)
+#if defined(__linux__) && defined(HAVE_RB_THREAD_BLOCKING_REGION)
 static int accept4_flags = SOCK_CLOEXEC;
 #else /* ! linux */
 static int accept4_flags = SOCK_CLOEXEC | SOCK_NONBLOCK;
@@ -125,6 +125,10 @@ static int thread_accept(struct accept_args *a, int force_nonblock)
 
         /* always use non-blocking accept() under 1.8 for green threads */
         set_nonblocking(a->fd);
+
+        /* created sockets are always non-blocking under 1.8, too */
+        a->flags |= SOCK_NONBLOCK;
+
         TRAP_BEG;
         rv = (int)xaccept(a);
         TRAP_END;