Comparison

net/server_select.lua @ 2740:2442c54cf9ec

net.server_select: Fix for traceback when a read returns an error and no data (thanks dersd)
author Matthew Wild <mwild1@gmail.com>
date Fri, 05 Mar 2010 16:45:46 +0000
parent 2732:dabdc56561f9
child 2925:692b3c6c5bd2
child 2997:6ccaefea80ec
comparison
equal deleted inserted replaced
2739:7339c2720b39 2740:2442c54cf9ec
428 end 428 end
429 return noread, nosend 429 return noread, nosend
430 end 430 end
431 local _readbuffer = function( ) -- this function reads data 431 local _readbuffer = function( ) -- this function reads data
432 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern" 432 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern"
433 if not err or (err == "wantread" or err == "timeout") or string_len(part) > 0 then -- received something 433 if not err or (err == "wantread" or err == "timeout") or (part and string_len(part) > 0) then -- received something
434 local buffer = buffer or part or "" 434 local buffer = buffer or part or ""
435 local len = string_len( buffer ) 435 local len = string_len( buffer )
436 if len > maxreadlen then 436 if len > maxreadlen then
437 disconnect( handler, "receive buffer exceeded" ) 437 disconnect( handler, "receive buffer exceeded" )
438 handler:close( true ) 438 handler:close( true )