Software /
code /
clix
Diff
clix.lua @ 45:36f5bf718d3c
clix.lua: Close connection immediately rather than delaying if send buffer is empty (thanks Florob)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 14 Dec 2010 20:18:56 +0000 |
parent | 43:1ec64b321834 |
child | 52:95ea1dca92ed |
line wrap: on
line diff
--- a/clix.lua Wed Sep 15 16:54:21 2010 +0100 +++ b/clix.lua Tue Dec 14 20:18:56 2010 +0000 @@ -101,7 +101,7 @@ local _real_close = conn.close; function conn:close() conn:debug("Delaying close..."); - conn:hook("drained", function () + local function close_conn() local function do_close() if _real_close then conn:debug("Closing now..."); @@ -116,7 +116,12 @@ else do_close(); end - end); + end + if conn.conn:bufferlen() == 0 then + close_conn(); + else + conn:hook("drained", close_conn); + end end -- /COMPAT