Mercurial > prosody-hg
comparison net/server_event.lua @ 5963:3bd90108cc3c
net/server: addclient: wrapclient already calls startconnection for us
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Wed, 18 Dec 2013 18:11:47 -0500 |
| parents | 27eacbb6e71f |
| children | 99d55f12a26f |
comparison
equal
deleted
inserted
replaced
| 5962:27eacbb6e71f | 5963:3bd90108cc3c |
|---|---|
| 126 end | 126 end |
| 127 function interface_mt:_close() | 127 function interface_mt:_close() |
| 128 return self:_destroy(); | 128 return self:_destroy(); |
| 129 end | 129 end |
| 130 | 130 |
| 131 function interface_mt:_start_connection(plainssl) -- should be called from addclient | 131 function interface_mt:_start_connection(plainssl) -- called from wrapclient |
| 132 local callback = function( event ) | 132 local callback = function( event ) |
| 133 if EV_TIMEOUT == event then -- timeout during connection | 133 if EV_TIMEOUT == event then -- timeout during connection |
| 134 self.fatalerror = "connection timeout" | 134 self.fatalerror = "connection timeout" |
| 135 self:ontimeout() -- call timeout listener | 135 self:ontimeout() -- call timeout listener |
| 136 self:_close() | 136 self:_close() |
| 749 client:settimeout( 0 ) -- set nonblocking | 749 client:settimeout( 0 ) -- set nonblocking |
| 750 local res, err = client:connect( addr, serverport ) -- connect | 750 local res, err = client:connect( addr, serverport ) -- connect |
| 751 if res or ( err == "timeout" ) then | 751 if res or ( err == "timeout" ) then |
| 752 local ip, port = client:getsockname( ) | 752 local ip, port = client:getsockname( ) |
| 753 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx ) | 753 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx ) |
| 754 interface:_start_connection( startssl ) | |
| 755 debug( "new connection id:", interface.id ) | 754 debug( "new connection id:", interface.id ) |
| 756 return interface, err | 755 return interface, err |
| 757 else | 756 else |
| 758 debug( "new connection failed:", err ) | 757 debug( "new connection failed:", err ) |
| 759 return nil, err | 758 return nil, err |
