Software /
code /
prosody
Comparison
net/server_event.lua @ 7420:3fc5560557a5
net.server_event: Schedule another read callback if there is still data left in buffer after reading (fixes #583 for real)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 04 May 2016 15:29:11 +0200 |
parent | 7419:325c03f5481b |
child | 7422:41be97f8158f |
child | 7688:88ad2d5bcf80 |
comparison
equal
deleted
inserted
replaced
7419:325c03f5481b | 7420:3fc5560557a5 |
---|---|
28 ACCEPT_DELAY = 10, -- seconds to wait until the next attempt of a full server to accept | 28 ACCEPT_DELAY = 10, -- seconds to wait until the next attempt of a full server to accept |
29 READ_TIMEOUT = 60 * 60 * 6, -- timeout in seconds for read data from socket | 29 READ_TIMEOUT = 60 * 60 * 6, -- timeout in seconds for read data from socket |
30 WRITE_TIMEOUT = 180, -- timeout in seconds for write data on socket | 30 WRITE_TIMEOUT = 180, -- timeout in seconds for write data on socket |
31 CONNECT_TIMEOUT = 20, -- timeout in seconds for connection attempts | 31 CONNECT_TIMEOUT = 20, -- timeout in seconds for connection attempts |
32 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) | 32 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) |
33 READ_RETRY_DELAY = 1e-06, -- if, after reading, there is still data in buffer, wait this long and continue reading | |
33 DEBUG = true, -- show debug messages | 34 DEBUG = true, -- show debug messages |
34 } | 35 } |
35 | 36 |
36 local pairs = pairs | 37 local pairs = pairs |
37 local select = select | 38 local select = select |
557 if interface.noreading or interface.fatalerror then -- leave this event | 558 if interface.noreading or interface.fatalerror then -- leave this event |
558 --vdebug( "leaving this event because:", tostring(interface.noreading or interface.fatalerror) ) | 559 --vdebug( "leaving this event because:", tostring(interface.noreading or interface.fatalerror) ) |
559 interface.eventread = nil | 560 interface.eventread = nil |
560 return -1 | 561 return -1 |
561 end | 562 end |
562 if EV_TIMEOUT == event and interface:onreadtimeout() ~= true then | 563 if EV_TIMEOUT == event and not interface.conn:dirty() and interface:onreadtimeout() ~= true then |
563 return -1 -- took too long to get some data from client -> disconnect | 564 return -1 -- took too long to get some data from client -> disconnect |
564 end | 565 end |
565 if interface._usingssl then -- handle luasec | 566 if interface._usingssl then -- handle luasec |
566 if interface.eventwritetimeout then -- ok, in the past writecallback was regged | 567 if interface.eventwritetimeout then -- ok, in the past writecallback was regged |
567 local ret = interface.writecallback( ) -- call it | 568 local ret = interface.writecallback( ) -- call it |
603 end | 604 end |
604 if interface.noreading then | 605 if interface.noreading then |
605 interface.eventread = nil; | 606 interface.eventread = nil; |
606 return -1; | 607 return -1; |
607 end | 608 end |
609 if interface.conn:dirty() then -- still data left in buffer | |
610 return EV_TIMEOUT, cfg.READ_RETRY_DELAY; | |
611 end | |
608 return EV_READ, cfg.READ_TIMEOUT | 612 return EV_READ, cfg.READ_TIMEOUT |
609 end | 613 end |
610 | 614 |
611 client:settimeout( 0 ) -- set non blocking | 615 client:settimeout( 0 ) -- set non blocking |
612 setmetatable(interface, interface_mt) | 616 setmetatable(interface, interface_mt) |