summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@mailme.dk>2013-01-28 13:25:10 +0100
committerEmil Renner Berthing <esmil@mailme.dk>2013-01-28 13:28:13 +0100
commited8fe903ec2344a341eefdfaa117a6b937d4b3bc (patch)
tree3326abaf06e47efad0d428226e4a2f64574df2d1
parentee2a1ce9b399bcd6cf06d797ecf6b81d0a4b967f (diff)
downloadlem-ed8fe903ec2344a341eefdfaa117a6b937d4b3bc.tar.gz
lem-ed8fe903ec2344a341eefdfaa117a6b937d4b3bc.tar.xz
lem-ed8fe903ec2344a341eefdfaa117a6b937d4b3bc.zip
io: don't try to emulate TCP_CORK with TCP_NOPUSH
OSX and some versions FreeBSD doesn't send data immediately after unsetting TCP_NOPUSH. On OSX if you set TCP_NOPUSH, write data and then unset TCP_NOPUSH you'll get a 2 second delay before the last data is sent. Unfortunately I've found no reliable work-around.
-rw-r--r--lem/io.lua9
-rw-r--r--lem/io/core.c2
-rw-r--r--lem/io/stream.c6
3 files changed, 13 insertions, 4 deletions
diff --git a/lem/io.lua b/lem/io.lua
index 41d7732..26f4274 100644
--- a/lem/io.lua
+++ b/lem/io.lua
@@ -69,6 +69,15 @@ do
end
end
+if not io.Stream.cork then
+ function io.Stream:cork()
+ return nil, 'Operation not supported'
+ end
+ function io.Stream:uncork()
+ return nil, 'Operation not supported'
+ end
+end
+
do
local MultiServer = {}
MultiServer.__index = MultiServer
diff --git a/lem/io/core.c b/lem/io/core.c
index 6f7aa8b..b282583 100644
--- a/lem/io/core.c
+++ b/lem/io/core.c
@@ -322,12 +322,14 @@ luaopen_lem_io_core(lua_State *L)
/* mt.write = <stream_write> */
lua_pushcfunction(L, stream_write);
lua_setfield(L, -2, "write");
+#ifdef TCP_CORK
/* mt.cork = <stream_cork> */
lua_pushcfunction(L, stream_cork);
lua_setfield(L, -2, "cork");
/* mt.uncork = <stream_uncork> */
lua_pushcfunction(L, stream_uncork);
lua_setfield(L, -2, "uncork");
+#endif
/* mt.getpeer = <stream_getpeer> */
lua_pushcfunction(L, stream_getpeer);
lua_setfield(L, -2, "getpeer");
diff --git a/lem/io/stream.c b/lem/io/stream.c
index b2b8f00..07aa5d2 100644
--- a/lem/io/stream.c
+++ b/lem/io/stream.c
@@ -290,10 +290,7 @@ stream_write(lua_State *T)
return lua_yield(T, top);
}
-#ifndef TCP_CORK
-#define TCP_CORK TCP_NOPUSH
-#endif
-
+#ifdef TCP_CORK
static int
stream_setcork(lua_State *T, int state)
{
@@ -324,6 +321,7 @@ stream_uncork(lua_State *T)
{
return stream_setcork(T, 0);
}
+#endif
static int
stream_getpeer(lua_State *T)