Software /
code /
prosody
Comparison
net/server_event.lua @ 2656:9fab59009397
net.server_event: Increase SSL handshake timeout to 30s, make handshake round-trip count configurable, and bump connect timeout to 20s (thanks Flo)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 17 Feb 2010 13:21:33 +0000 |
parent | 2641:b083a667e3be |
child | 2660:9e5b21b7b2f9 |
comparison
equal
deleted
inserted
replaced
2654:07a6f5f9d4be | 2656:9fab59009397 |
---|---|
18 local SCRIPT_AUTHOR = "blastbeat" | 18 local SCRIPT_AUTHOR = "blastbeat" |
19 local LAST_MODIFIED = "2009/11/20" | 19 local LAST_MODIFIED = "2009/11/20" |
20 | 20 |
21 local cfg = { | 21 local cfg = { |
22 MAX_CONNECTIONS = 100000, -- max per server connections (use "ulimit -n" on *nix) | 22 MAX_CONNECTIONS = 100000, -- max per server connections (use "ulimit -n" on *nix) |
23 MAX_HANDSHAKE_ATTEMPS = 10, -- attemps to finish ssl handshake | 23 MAX_HANDSHAKE_ATTEMPS = 1000, -- attemps to finish ssl handshake |
24 HANDSHAKE_TIMEOUT = 1, -- timout in seconds per handshake attemp | 24 HANDSHAKE_TIMEOUT = 30, -- timout in seconds per handshake attemp |
25 MAX_READ_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes allowed to read from sockets | 25 MAX_READ_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes allowed to read from sockets |
26 MAX_SEND_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes size of write buffer (for writing on sockets) | 26 MAX_SEND_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes size of write buffer (for writing on sockets) |
27 ACCEPT_DELAY = 10, -- seconds to wait until the next attemp of a full server to accept | 27 ACCEPT_DELAY = 10, -- seconds to wait until the next attemp of a full server to accept |
28 READ_TIMEOUT = 60 * 30, -- timeout in seconds for read data from socket | 28 READ_TIMEOUT = 60 * 30, -- timeout in seconds for read data from socket |
29 WRITE_TIMEOUT = 30, -- timeout in seconds for write data on socket | 29 WRITE_TIMEOUT = 30, -- timeout in seconds for write data on socket |
30 CONNECT_TIMEOUT = 10, -- timeout in seconds for connection attemps | 30 CONNECT_TIMEOUT = 20, -- timeout in seconds for connection attemps |
31 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) | 31 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) |
32 DEBUG = true, -- show debug messages | 32 DEBUG = true, -- show debug messages |
33 } | 33 } |
34 | 34 |
35 local function use(x) return rawget(_G, x); end | 35 local function use(x) return rawget(_G, x); end |
195 local handshakecallback = coroutine_wrap( | 195 local handshakecallback = coroutine_wrap( |
196 function( event ) | 196 function( event ) |
197 local _, err | 197 local _, err |
198 local attempt = 0 | 198 local attempt = 0 |
199 local maxattempt = cfg.MAX_HANDSHAKE_ATTEMPS | 199 local maxattempt = cfg.MAX_HANDSHAKE_ATTEMPS |
200 while attempt < 1000 do -- no endless loop | 200 while attempt < maxattempt do -- no endless loop |
201 attempt = attempt + 1 | 201 attempt = attempt + 1 |
202 debug( "ssl handshake of client with id:"..tostring(self).."attemp:"..attempt ) | 202 debug( "ssl handshake of client with id:"..tostring(self).."attemp:"..attempt ) |
203 if attempt > maxattempt then | 203 if attempt > maxattempt then |
204 self.fatalerror = "max handshake attemps exceeded" | 204 self.fatalerror = "max handshake attemps exceeded" |
205 elseif EV_TIMEOUT == event then | 205 elseif EV_TIMEOUT == event then |