about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-14 19:35:01 +0000
committerEric Wong <normalperson@yhbt.net>2011-03-14 19:35:01 +0000
commit6299ef55e20454eaca0b9860ac4a9bd6ddd143a7 (patch)
tree338c212cc89c8946537bf858739aab4b44d49db9
parent59ed57abf542b89babf595e5508cba42ceb9fd47 (diff)
downloadkgio-6299ef55e20454eaca0b9860ac4a9bd6ddd143a7.tar.gz
It's in Ruby 1.9.3dev and tracks waiting FDs on blocked threads.
-rw-r--r--ext/kgio/accept.c3
-rw-r--r--ext/kgio/blocking_io_region.h6
-rw-r--r--ext/kgio/extconf.rb1
3 files changed, 9 insertions, 1 deletions
diff --git a/ext/kgio/accept.c b/ext/kgio/accept.c
index 902145c..2026a78 100644
--- a/ext/kgio/accept.c
+++ b/ext/kgio/accept.c
@@ -69,6 +69,7 @@ static VALUE xaccept(void *ptr)
 
 #ifdef HAVE_RB_THREAD_BLOCKING_REGION
 #  include <time.h>
+#  include "blocking_io_region.h"
 /*
  * Try to use a (real) blocking accept() since that can prevent
  * thundering herds under Linux:
@@ -82,7 +83,7 @@ static int thread_accept(struct accept_args *a, int force_nonblock)
 {
         if (force_nonblock)
                 set_nonblocking(a->fd);
-        return (int)rb_thread_blocking_region(xaccept, a, RUBY_UBF_IO, 0);
+        return (int)rb_thread_io_blocking_region(xaccept, a, a->fd);
 }
 
 static void set_blocking_or_block(int fd)
diff --git a/ext/kgio/blocking_io_region.h b/ext/kgio/blocking_io_region.h
new file mode 100644
index 0000000..c872b53
--- /dev/null
+++ b/ext/kgio/blocking_io_region.h
@@ -0,0 +1,6 @@
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#  ifndef HAVE_RB_THREAD_IO_BLOCKING_REGION
+#    define rb_thread_io_blocking_region(fn,data,fd) \
+            rb_thread_blocking_region((fn),(data),RUBY_UBF_IO,0)
+#  endif
+#endif
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb
index d7f1299..a0def1d 100644
--- a/ext/kgio/extconf.rb
+++ b/ext/kgio/extconf.rb
@@ -27,6 +27,7 @@ have_type("struct RObject") and check_sizeof("struct RObject")
 check_sizeof("int")
 have_func('rb_io_ascii8bit_binmode')
 have_func('rb_thread_blocking_region')
+have_func('rb_thread_io_blocking_region')
 have_func('rb_str_set_len')
 
 dir_config('kgio')