# HG changeset patch # User Kim Alvefur # Date 1343241200 -7200 # Node ID 2f8f388de516dd53eead3c2dad7056122ea751f7 # Parent b27ba2c83dd4304e2af13239f474862f3ab37c0f net.server_event: Don't emit empty packets, check for errors first. (fixes #287) diff -r b27ba2c83dd4 -r 2f8f388de516 net/server_event.lua --- a/net/server_event.lua Wed Jul 25 20:31:14 2012 +0200 +++ b/net/server_event.lua Wed Jul 25 20:33:20 2012 +0200 @@ -597,16 +597,14 @@ end local buffer, err, part = interface.conn:receive( interface._pattern ) -- receive buffer with "pattern" --vdebug( "read data:", tostring(buffer), "error:", tostring(err), "part:", tostring(part) ) - buffer = buffer or part or "" - local len = string_len( buffer ) - if len > cfg.MAX_READ_LENGTH then -- check buffer length + buffer = buffer or part + if buffer and #buffer > cfg.MAX_READ_LENGTH then -- check buffer length interface.fatalerror = "receive buffer exceeded" debug( "fatal error:", interface.fatalerror ) interface:_close() interface.eventread = nil return -1 end - interface.onincoming( interface, buffer, err ) -- send new data to listener if err and ( err ~= "timeout" and err ~= "wantread" ) then if "wantwrite" == err then -- need to read on write event if not interface.eventwrite then -- register new write event if needed @@ -626,6 +624,8 @@ interface.eventread = nil return -1 end + else + interface.onincoming( interface, buffer, err ) -- send new data to listener end if interface.noreading then interface.eventread = nil;