about summary refs log tree commit homepage
path: root/ext/io_splice
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-26 16:35:56 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-26 16:42:29 -0800
commit24a2f6db438537ff81081a41b5ebf02cda2dec57 (patch)
treef4758fc08238d7e094aa6d1fcae4c704f09bcde9 /ext/io_splice
parent844ed3d36faf14813a2e6f2476920f63bcb3bc89 (diff)
downloadruby_io_splice-24a2f6db438537ff81081a41b5ebf02cda2dec57.tar.gz
Long lines bother me
Diffstat (limited to 'ext/io_splice')
-rw-r--r--ext/io_splice/io_splice_ext.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c
index 268179f..35dc4a2 100644
--- a/ext/io_splice/io_splice_ext.c
+++ b/ext/io_splice/io_splice_ext.c
@@ -90,8 +90,14 @@ rb_thread_blocking_region(
 #  define RARRAY_LEN(s) (RARRAY(s)->len)
 #endif
 
+static VALUE io_run(rb_blocking_function_t *fn, void *data)
+{
+        return rb_thread_blocking_region(fn, data, RUBY_UBF_IO, 0);
+}
+
 /*
  * Releases GVL only iff blocking I/O is used.
+ * Only use this if all file descriptors in data are pipes.
  * We'll trust programmers who use non-blocking I/O explicitly to
  * want the fastest possible performance without resorting to threads,
  * so releasing and them immediately reacquiring the GVL would be
@@ -101,7 +107,7 @@ static VALUE nb_io_run(rb_blocking_function_t *fn, void *data, unsigned flags)
 {
         if (flags & SPLICE_F_NONBLOCK)
                 return fn(data);
-        return rb_thread_blocking_region(fn, data, RUBY_UBF_IO, 0);
+        return io_run(fn, data);
 }
 
 struct splice_args {
@@ -180,7 +186,7 @@ VALUE fd_in, VALUE off_in, VALUE fd_out, VALUE off_out, VALUE len, VALUE flags)
         struct splice_args a;
 
         prepare_splice_args(&a, fd_in, off_in, fd_out, off_out, len, flags);
-        n = (long)rb_thread_blocking_region(nogvl_splice, &a, RUBY_UBF_IO, 0);
+        n = (long)io_run(nogvl_splice, &a);
         if (n == 0)
                 rb_eof_error();
         if (n < 0)
@@ -195,7 +201,7 @@ VALUE fd_in, VALUE off_in, VALUE fd_out, VALUE off_out, VALUE len, VALUE flags)
         struct splice_args a;
 
         prepare_splice_args(&a, fd_in, off_in, fd_out, off_out, len, flags);
-        n = (long)rb_thread_blocking_region(nogvl_splice, &a, RUBY_UBF_IO, 0);
+        n = (long)io_run(nogvl_splice, &a);
         if (n == 0)
                 return Qnil;
         if (n < 0) {