Software /
code /
prosody
Comparison
net/server_select.lua @ 2302:2dc9bbf25447
net.server_select: Fix possibility of losing data sent from a socket just before it closes (thanks Sjoerd Simons)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 03 Dec 2009 02:28:34 +0000 |
parent | 2250:3196dabe8a36 |
child | 2304:26f59e5e5c03 |
comparison
equal
deleted
inserted
replaced
2301:8a01b0898679 | 2302:2dc9bbf25447 |
---|---|
465 end | 465 end |
466 return noread, nosend | 466 return noread, nosend |
467 end | 467 end |
468 local _readbuffer = function( ) -- this function reads data | 468 local _readbuffer = function( ) -- this function reads data |
469 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern" | 469 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern" |
470 if not err or ( err == "timeout" or err == "wantread" ) then -- received something | 470 if not err or string_len(part) > 0 then -- received something |
471 local buffer = buffer or part or "" | 471 local buffer = buffer or part or "" |
472 local len = string_len( buffer ) | 472 local len = string_len( buffer ) |
473 if len > maxreadlen then | 473 if len > maxreadlen then |
474 disconnect( handler, "receive buffer exceeded" ) | 474 disconnect( handler, "receive buffer exceeded" ) |
475 handler.close( true ) | 475 handler.close( true ) |