about summary refs log tree commit homepage
path: root/ext/kgio/read_write.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-27 19:43:39 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-27 19:45:52 -0800
commit910f6f3df099c04fcd55bd6b20785cce69cb36ae (patch)
tree4cc051bc7155b0b655a44fa19666a8870c5ece49 /ext/kgio/read_write.c
parentec91ac3d8c8d9236ba0cd01794c9c4a3ee3f7eeb (diff)
downloadkgio-910f6f3df099c04fcd55bd6b20785cce69cb36ae.tar.gz
It only supports TCP_CORK under Linux right now.

We use a very basic strategy to use TCP_CORK semantics optimally
in most TCP servers:  On corked sockets, we will uncork on recv()
if there was a previous send().  Otherwise we do not fiddle
with TCP_CORK at all.

Under Linux, we can rely on TCP_CORK being inherited in an
accept()-ed client socket so we can avoid syscalls for each
accept()-ed client if we already know the accept() socket corks.

This module does NOTHING for client TCP sockets, we only deal
with accept()-ed sockets right now.
Diffstat (limited to 'ext/kgio/read_write.c')
-rw-r--r--ext/kgio/read_write.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c
index 7ba2925..a954865 100644
--- a/ext/kgio/read_write.c
+++ b/ext/kgio/read_write.c
@@ -164,6 +164,7 @@ static VALUE my_recv(int io_wait, int argc, VALUE *argv, VALUE io)
         long n;
 
         prepare_read(&a, argc, argv, io);
+        kgio_nopush_recv(io, a.fd);
 
         if (a.len > 0) {
 retry:
@@ -320,6 +321,8 @@ retry:
         n = (long)send(a.fd, a.ptr, a.len, MSG_DONTWAIT);
         if (write_check(&a, n, "send", io_wait) != 0)
                 goto retry;
+        if (TYPE(a.buf) != T_SYMBOL)
+                kgio_nopush_send(io, a.fd);
         return a.buf;
 }