Software /
code /
prosody
Comparison
net/server_event.lua @ 7339:b5565715fce8
server_event: addclient: wrapclient already calls startconnection for us [backported from trunk]
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 18 Dec 2013 18:11:47 -0500 |
parent | 7337:8ec935687bae |
child | 7341:aa94cd27df4d |
child | 7385:17929cdacec2 |
comparison
equal
deleted
inserted
replaced
7337:8ec935687bae | 7339:b5565715fce8 |
---|---|
95 -- Private methods | 95 -- Private methods |
96 function interface_mt:_close() | 96 function interface_mt:_close() |
97 return self:_destroy(); | 97 return self:_destroy(); |
98 end | 98 end |
99 | 99 |
100 function interface_mt:_start_connection(plainssl) -- should be called from addclient | 100 function interface_mt:_start_connection(plainssl) -- called from wrapclient |
101 local callback = function( event ) | 101 local callback = function( event ) |
102 if EV_TIMEOUT == event then -- timeout during connection | 102 if EV_TIMEOUT == event then -- timeout during connection |
103 self.fatalerror = "connection timeout" | 103 self.fatalerror = "connection timeout" |
104 self:ontimeout() -- call timeout listener | 104 self:ontimeout() -- call timeout listener |
105 self:_close() | 105 self:_close() |
728 client:settimeout( 0 ) -- set nonblocking | 728 client:settimeout( 0 ) -- set nonblocking |
729 local res, err = client:connect( addr, serverport ) -- connect | 729 local res, err = client:connect( addr, serverport ) -- connect |
730 if res or ( err == "timeout" ) then | 730 if res or ( err == "timeout" ) then |
731 local ip, port = client:getsockname( ) | 731 local ip, port = client:getsockname( ) |
732 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx ) | 732 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx ) |
733 interface:_start_connection( sslctx ) | |
734 debug( "new connection id:", interface.id ) | 733 debug( "new connection id:", interface.id ) |
735 return interface, err | 734 return interface, err |
736 else | 735 else |
737 debug( "new connection failed:", err ) | 736 debug( "new connection failed:", err ) |
738 return nil, err | 737 return nil, err |