aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-07-25 20:33:20 +0200
committerKim Alvefur <zash@zash.se>2012-07-25 20:33:20 +0200
commitfac697c2cdde2a98dbbadca2b1dc2685a58c6462 (patch)
treeb4a8a9496ec213b8f8587d5c1c838c3ba3528495 /net
parentc373b78e0e0eb7a354f90071a2ae408811c9ccb6 (diff)
downloadprosody-fac697c2cdde2a98dbbadca2b1dc2685a58c6462.tar.gz
prosody-fac697c2cdde2a98dbbadca2b1dc2685a58c6462.zip
net.server_event: Don't emit empty packets, check for errors first. (fixes #287)
Diffstat (limited to 'net')
-rw-r--r--net/server_event.lua8
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;