diff options
-rw-r--r-- | core/moduleapi.lua | 9 | ||||
-rw-r--r-- | net/server.lua | 1 | ||||
-rw-r--r-- | net/server_event.lua | 1 | ||||
-rw-r--r-- | net/server_select.lua | 8 | ||||
-rw-r--r-- | plugins/mod_s2s/mod_s2s.lua | 13 | ||||
-rwxr-xr-x | prosodyctl | 8 |
6 files changed, 27 insertions, 13 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 9baf4fba..ed75669b 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -319,7 +319,13 @@ function api:handle_items(type, added_cb, removed_cb, existing) end function api:provides(name, item) - if not item then item = self.environment; end + -- if not item then item = setmetatable({}, { __index = function(t,k) return rawget(self.environment, k); end }); end + if not item then + item = {} + for k,v in pairs(self.environment) do + if k ~= "module" then item[k] = v; end + end + end if not item.name then local item_name = self.name; -- Strip a provider prefix to find the item name @@ -329,6 +335,7 @@ function api:provides(name, item) end item.name = item_name; end + item._provided_by = self.name; self:add_item(name.."-provider", item); end 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 diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index a935239e..30ebb706 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -348,7 +348,7 @@ function stream_callbacks.streamopened(session, attr) end end - session:open_stream() + session:open_stream(session.to_host, session.from_host) if session.version >= 1.0 then local features = st.stanza("stream:features"); @@ -448,7 +448,11 @@ local function session_close(session, reason, remote_reason) local log = session.log or log; if session.conn then if session.notopen then - session:open_stream() + if session.direction == "incoming" then + session:open_stream(session.to_host, session.from_host); + else + session:open_stream(session.from_host, session.to_host); + end end if reason then -- nil == no err, initiated by us, false == initiated by remote if type(reason) == "string" then -- assume stream error @@ -496,8 +500,6 @@ local function session_close(session, reason, remote_reason) end function session_open_stream(session, from, to) - local from = from or session.from_host; - local to = to or session.to_host; local attr = { ["xmlns:stream"] = 'http://etherx.jabber.org/streams', xmlns = 'jabber:server', @@ -506,8 +508,7 @@ function session_open_stream(session, from, to) id = session.streamid, from = from, to = to, } - local local_host = session.direction == "outgoing" and from or to; - if not local_host or (hosts[local_host] and hosts[local_host].modules.dialback) then + if not from or (hosts[from] and hosts[from].modules.dialback) then attr["xmlns:db"] = 'jabber:server:dialback'; end @@ -654,7 +654,7 @@ end function cert_commands.config(arg) if #arg >= 1 and arg[1] ~= "--help" then - local conf_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".cnf"; + local conf_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".cnf"; if ask_overwrite(conf_filename) then return nil, conf_filename; end @@ -687,7 +687,7 @@ end function cert_commands.key(arg) if #arg >= 1 and arg[1] ~= "--help" then - local key_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".key"; + local key_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".key"; if ask_overwrite(key_filename) then return nil, key_filename; end @@ -709,7 +709,7 @@ end function cert_commands.request(arg) if #arg >= 1 and arg[1] ~= "--help" then - local req_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".req"; + local req_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".req"; if ask_overwrite(req_filename) then return nil, req_filename; end @@ -727,7 +727,7 @@ end function cert_commands.generate(arg) if #arg >= 1 and arg[1] ~= "--help" then - local cert_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".crt"; + local cert_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".crt"; if ask_overwrite(cert_filename) then return nil, cert_filename; end |