diff options
author | Kim Alvefur <zash@zash.se> | 2012-07-25 20:33:20 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-07-25 20:33:20 +0200 |
commit | 7f3c5bae633adf3d19aef14d545b0fede000c545 (patch) | |
tree | b4a8a9496ec213b8f8587d5c1c838c3ba3528495 /net/server_event.lua | |
parent | fe4e7ec80f11408df9ebbfed5ba16e50262658a2 (diff) | |
download | prosody-7f3c5bae633adf3d19aef14d545b0fede000c545.tar.gz prosody-7f3c5bae633adf3d19aef14d545b0fede000c545.zip |
net.server_event: Don't emit empty packets, check for errors first. (fixes #287)
Diffstat (limited to 'net/server_event.lua')
-rw-r--r-- | net/server_event.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/server_event.lua b/net/server_event.lua index de44e5fd..264d50a7 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -597,16 +597,14 @@ do 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 @@ do 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; |