From fc5911e5ebe3561aeb3df94437ee8b1504fc318b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 4 May 2016 15:20:33 +0200 Subject: net.server_event: Collect entire one line function on one line --- net/server_event.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'net/server_event.lua') diff --git a/net/server_event.lua b/net/server_event.lua index 1329a43d..e0dc175f 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -588,10 +588,7 @@ local function handleclient( client, ip, port, server, pattern, listener, sslctx interface.eventwrite = addevent( base, interface.conn, EV_WRITE, interface.writecallback, cfg.WRITE_TIMEOUT ) end interface.eventreadtimeout = addevent( base, nil, EV_TIMEOUT, - function( ) - interface:_close() - end, cfg.READ_TIMEOUT - ) + function( ) interface:_close() end, cfg.READ_TIMEOUT) debug( "wantwrite during read attempt, reg it in writecallback but dont know what really happens next..." ) -- to be honest i dont know what happens next, if it is allowed to first read, the write etc... else -- connection was closed or fatal error -- cgit v1.2.3 From f724f446d5e71d16a5c7a903efa795061e07978c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 4 May 2016 15:29:11 +0200 Subject: net.server_event: Schedule another read callback if there is still data left in buffer after reading (fixes #583 for real) --- net/server_event.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'net/server_event.lua') diff --git a/net/server_event.lua b/net/server_event.lua index e0dc175f..2cb45553 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -30,6 +30,7 @@ local cfg = { WRITE_TIMEOUT = 180, -- timeout in seconds for write data on socket CONNECT_TIMEOUT = 20, -- timeout in seconds for connection attempts CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) + READ_RETRY_DELAY = 1e-06, -- if, after reading, there is still data in buffer, wait this long and continue reading DEBUG = true, -- show debug messages } @@ -559,7 +560,7 @@ local function handleclient( client, ip, port, server, pattern, listener, sslctx interface.eventread = nil return -1 end - if EV_TIMEOUT == event and interface:onreadtimeout() ~= true then + if EV_TIMEOUT == event and not interface.conn:dirty() and interface:onreadtimeout() ~= true then return -1 -- took too long to get some data from client -> disconnect end if interface._usingssl then -- handle luasec @@ -605,6 +606,9 @@ local function handleclient( client, ip, port, server, pattern, listener, sslctx interface.eventread = nil; return -1; end + if interface.conn:dirty() then -- still data left in buffer + return EV_TIMEOUT, cfg.READ_RETRY_DELAY; + end return EV_READ, cfg.READ_TIMEOUT end -- cgit v1.2.3