aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-04-27 22:46:01 +0200
committerKim Alvefur <zash@zash.se>2013-04-27 22:46:01 +0200
commite5dc6ab94332c397431b40748ef0a486b8617e82 (patch)
treee88168af92a11e7b30a5179f57ac7f3935ab2be8
parent3f516c749d334a0ad26a7b1b8111d0207a556e95 (diff)
downloadprosody-e5dc6ab94332c397431b40748ef0a486b8617e82.tar.gz
prosody-e5dc6ab94332c397431b40748ef0a486b8617e82.zip
net.server*: Allow the TCP backlog parameter to be set in the config
-rw-r--r--net/server.lua1
-rw-r--r--net/server_event.lua1
-rw-r--r--net/server_select.lua8
3 files changed, 8 insertions, 2 deletions
diff --git a/net/server.lua b/net/server.lua
index ae3d45b0..375e7081 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -51,6 +51,7 @@ if prosody then
if use_luaevent then
local event_settings = {
ACCEPT_DELAY = settings.event_accept_retry_interval;
+ ACCEPT_QUEUE = settings.tcp_backlog;
CLEAR_DELAY = settings.event_clear_interval;
CONNECT_TIMEOUT = settings.connect_timeout;
DEBUG = settings.debug;
diff --git a/net/server_event.lua b/net/server_event.lua
index b34845d6..5eae95a9 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -23,6 +23,7 @@ local cfg = {
HANDSHAKE_TIMEOUT = 60, -- timeout in seconds per handshake attempt
MAX_READ_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes allowed to read from sockets
MAX_SEND_LENGTH = 1024 * 1024 * 1024 * 1024, -- max bytes size of write buffer (for writing on sockets)
+ ACCEPT_QUEUE = 128, -- might influence the length of the pending sockets queue
ACCEPT_DELAY = 10, -- seconds to wait until the next attempt of a full server to accept
READ_TIMEOUT = 60 * 60 * 6, -- timeout in seconds for read data from socket
WRITE_TIMEOUT = 180, -- timeout in seconds for write data on socket
diff --git a/net/server_select.lua b/net/server_select.lua
index 28f1dc6d..bdf262ae 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -101,6 +101,7 @@ local _readtraffic
local _selecttimeout
local _sleeptime
+local _tcpbacklog
local _starttime
local _currenttime
@@ -139,6 +140,7 @@ _readtraffic = 0
_selecttimeout = 1 -- timeout of socket.select
_sleeptime = 0 -- time to wait at the end of every loop
+_tcpbacklog = 128 -- some kind of hint to the OS
_maxsendlen = 51000 * 1024 -- max len of send buffer
_maxreadlen = 25000 * 1024 -- max len of read buffer
@@ -211,7 +213,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx ) -- t
handler.resume = function( )
if handler.paused then
if not socket then
- socket = socket_bind( ip, serverport );
+ socket = socket_bind( ip, serverport, _tcpbacklog );
socket:settimeout( 0 )
end
_readlistlen = addsocket(_readlist, socket, _readlistlen)
@@ -720,7 +722,7 @@ addserver = function( addr, port, listeners, pattern, sslctx ) -- this function
return nil, err
end
addr = addr or "*"
- local server, err = socket_bind( addr, port )
+ local server, err = socket_bind( addr, port, _tcpbacklog )
if err then
out_error( "server.lua, [", addr, "]:", port, ": ", err )
return nil, err
@@ -772,6 +774,7 @@ getsettings = function( )
return {
select_timeout = _selecttimeout;
select_sleep_time = _sleeptime;
+ tcp_backlog = _tcpbacklog;
max_send_buffer_size = _maxsendlen;
max_receive_buffer_size = _maxreadlen;
select_idle_check_interval = _checkinterval;
@@ -792,6 +795,7 @@ changesettings = function( new )
_maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen
_maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen
_checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval
+ _tcpbacklog = tonumber( new.tcp_backlog ) or _tcpbacklog
_sendtimeout = tonumber( new.send_timeout ) or _sendtimeout
_readtimeout = tonumber( new.read_timeout ) or _readtimeout
_maxselectlen = new.max_connections or _maxselectlen