Software /
code /
prosody
Comparison
net/server_select.lua @ 5531:483f795f6f99
net.server*: Allow the TCP backlog parameter to be set in the config
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Apr 2013 22:46:01 +0200 |
parent | 5492:5d0cc5de5c51 |
child | 5548:c5d1c35c93f4 |
comparison
equal
deleted
inserted
replaced
5530:d83482fc4a81 | 5531:483f795f6f99 |
---|---|
99 local _sendtraffic | 99 local _sendtraffic |
100 local _readtraffic | 100 local _readtraffic |
101 | 101 |
102 local _selecttimeout | 102 local _selecttimeout |
103 local _sleeptime | 103 local _sleeptime |
104 local _tcpbacklog | |
104 | 105 |
105 local _starttime | 106 local _starttime |
106 local _currenttime | 107 local _currenttime |
107 | 108 |
108 local _maxsendlen | 109 local _maxsendlen |
137 _sendtraffic = 0 -- some stats | 138 _sendtraffic = 0 -- some stats |
138 _readtraffic = 0 | 139 _readtraffic = 0 |
139 | 140 |
140 _selecttimeout = 1 -- timeout of socket.select | 141 _selecttimeout = 1 -- timeout of socket.select |
141 _sleeptime = 0 -- time to wait at the end of every loop | 142 _sleeptime = 0 -- time to wait at the end of every loop |
143 _tcpbacklog = 128 -- some kind of hint to the OS | |
142 | 144 |
143 _maxsendlen = 51000 * 1024 -- max len of send buffer | 145 _maxsendlen = 51000 * 1024 -- max len of send buffer |
144 _maxreadlen = 25000 * 1024 -- max len of read buffer | 146 _maxreadlen = 25000 * 1024 -- max len of read buffer |
145 | 147 |
146 _checkinterval = 1200000 -- interval in secs to check idle clients | 148 _checkinterval = 1200000 -- interval in secs to check idle clients |
209 end | 211 end |
210 end | 212 end |
211 handler.resume = function( ) | 213 handler.resume = function( ) |
212 if handler.paused then | 214 if handler.paused then |
213 if not socket then | 215 if not socket then |
214 socket = socket_bind( ip, serverport ); | 216 socket = socket_bind( ip, serverport, _tcpbacklog ); |
215 socket:settimeout( 0 ) | 217 socket:settimeout( 0 ) |
216 end | 218 end |
217 _readlistlen = addsocket(_readlist, socket, _readlistlen) | 219 _readlistlen = addsocket(_readlist, socket, _readlistlen) |
218 _socketlist[ socket ] = handler | 220 _socketlist[ socket ] = handler |
219 handler.paused = false; | 221 handler.paused = false; |
718 if err then | 720 if err then |
719 out_error( "server.lua, [", addr, "]:", port, ": ", err ) | 721 out_error( "server.lua, [", addr, "]:", port, ": ", err ) |
720 return nil, err | 722 return nil, err |
721 end | 723 end |
722 addr = addr or "*" | 724 addr = addr or "*" |
723 local server, err = socket_bind( addr, port ) | 725 local server, err = socket_bind( addr, port, _tcpbacklog ) |
724 if err then | 726 if err then |
725 out_error( "server.lua, [", addr, "]:", port, ": ", err ) | 727 out_error( "server.lua, [", addr, "]:", port, ": ", err ) |
726 return nil, err | 728 return nil, err |
727 end | 729 end |
728 local handler, err = wrapserver( listeners, server, addr, port, pattern, sslctx ) -- wrap new server socket | 730 local handler, err = wrapserver( listeners, server, addr, port, pattern, sslctx ) -- wrap new server socket |
770 | 772 |
771 getsettings = function( ) | 773 getsettings = function( ) |
772 return { | 774 return { |
773 select_timeout = _selecttimeout; | 775 select_timeout = _selecttimeout; |
774 select_sleep_time = _sleeptime; | 776 select_sleep_time = _sleeptime; |
777 tcp_backlog = _tcpbacklog; | |
775 max_send_buffer_size = _maxsendlen; | 778 max_send_buffer_size = _maxsendlen; |
776 max_receive_buffer_size = _maxreadlen; | 779 max_receive_buffer_size = _maxreadlen; |
777 select_idle_check_interval = _checkinterval; | 780 select_idle_check_interval = _checkinterval; |
778 send_timeout = _sendtimeout; | 781 send_timeout = _sendtimeout; |
779 read_timeout = _readtimeout; | 782 read_timeout = _readtimeout; |
790 _selecttimeout = tonumber( new.select_timeout ) or _selecttimeout | 793 _selecttimeout = tonumber( new.select_timeout ) or _selecttimeout |
791 _sleeptime = tonumber( new.select_sleep_time ) or _sleeptime | 794 _sleeptime = tonumber( new.select_sleep_time ) or _sleeptime |
792 _maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen | 795 _maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen |
793 _maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen | 796 _maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen |
794 _checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval | 797 _checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval |
798 _tcpbacklog = tonumber( new.tcp_backlog ) or _tcpbacklog | |
795 _sendtimeout = tonumber( new.send_timeout ) or _sendtimeout | 799 _sendtimeout = tonumber( new.send_timeout ) or _sendtimeout |
796 _readtimeout = tonumber( new.read_timeout ) or _readtimeout | 800 _readtimeout = tonumber( new.read_timeout ) or _readtimeout |
797 _maxselectlen = new.max_connections or _maxselectlen | 801 _maxselectlen = new.max_connections or _maxselectlen |
798 _maxsslhandshake = new.max_ssl_handshake_roundtrips or _maxsslhandshake | 802 _maxsslhandshake = new.max_ssl_handshake_roundtrips or _maxsslhandshake |
799 _maxfd = new.highest_allowed_fd or _maxfd | 803 _maxfd = new.highest_allowed_fd or _maxfd |