about summary refs log tree commit homepage
path: root/ext/kgio/read.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-12-15 22:53:48 +0000
committerEric Wong <e@80x24.org>2016-12-15 23:51:08 +0000
commit333347c3ae54c8d605c673fcd11ff8dcb2ea4c38 (patch)
tree0663faa01cb9f84457a1b55ab52867ed986dd64c /ext/kgio/read.c
parent64dc570f4b99f68b5ed792b36e7e8abc3df74927 (diff)
downloadkgio-333347c3ae54c8d605c673fcd11ff8dcb2ea4c38.tar.gz
The regression for existing users was unnacceptable and
completely poor judgement on my part.  This change brings
us back to potentially not-future-compatible code which
will impose maintenance burdens on us in the face of
future Ruby changes.

But TODAY, it is the most performant option for folks who
need to use autopush.

Revert "resurrect Kgio.autopush support in pure Ruby"
and "remove autopush support and make it a no-op"

This reverts commits 64dc570f4b99f68b5ed792b36e7e8abc3df74927
and 4347980fa66115425fa8b765353c8b1bfe5dec24.
Diffstat (limited to 'ext/kgio/read.c')
-rw-r--r--ext/kgio/read.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/kgio/read.c b/ext/kgio/read.c
index e55db16..472a592 100644
--- a/ext/kgio/read.c
+++ b/ext/kgio/read.c
@@ -7,8 +7,13 @@ static VALUE sym_wait_readable;
 
 #ifdef USE_MSG_DONTWAIT
 static const int peek_flags = MSG_DONTWAIT|MSG_PEEK;
+
+/* we don't need these variants, we call kgio_autopush_recv directly */
+static inline void kgio_autopush_read(VALUE io) { }
+
 #else
 static const int peek_flags = MSG_PEEK;
+static inline void kgio_autopush_read(VALUE io) { kgio_autopush_recv(io); }
 #endif
 
 struct rd_args {
@@ -80,6 +85,7 @@ static VALUE my_read(int io_wait, int argc, VALUE *argv, VALUE io)
         long n;
 
         prepare_read(&a, argc, argv, io);
+        kgio_autopush_read(io);
 
         if (a.len > 0) {
                 set_nonblocking(a.fd);
@@ -152,6 +158,7 @@ static VALUE my_recv(int io_wait, int argc, VALUE *argv, VALUE io)
         long n;
 
         prepare_read(&a, argc, argv, io);
+        kgio_autopush_recv(io);
 
         if (a.len > 0) {
 retry:
@@ -205,6 +212,7 @@ static VALUE my_peek(int io_wait, int argc, VALUE *argv, VALUE io)
         long n;
 
         prepare_read(&a, argc, argv, io);
+        kgio_autopush_recv(io);
 
         if (a.len > 0) {
                 if (peek_flags == MSG_PEEK)