From 6cff8fa4749a367ac6dd4581a1e5bcfc4c8e3881 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Aug 2016 20:48:37 +0200 Subject: mod_s2s: Index session after checking if it exists (fixes traceback in case of a connection without a session having a read timeout) --- plugins/mod_s2s/mod_s2s.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index ea186cf0..ae9a746a 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -642,8 +642,8 @@ end function listener.onreadtimeout(conn) local session = sessions[conn]; - local host = session.host or session.to_host; if session then + local host = session.host or session.to_host; return (hosts[host] or prosody).events.fire_event("s2s-read-timeout", { session = session }); end end -- cgit v1.2.3 From 2c74295bfa5f749edd0f458ed9e8aadd23883bfe Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Aug 2016 20:49:50 +0200 Subject: util.table: Move loop variable to top of function for C89 compatibility --- util-src/table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util-src/table.c b/util-src/table.c index 423f8f29..63415541 100644 --- a/util-src/table.c +++ b/util-src/table.c @@ -7,10 +7,11 @@ static int Lcreate_table(lua_State* L) { } static int Lpack(lua_State* L) { + int arg; unsigned int n_args = lua_gettop(L); lua_createtable(L, n_args, 1); lua_insert(L, 1); - for(int arg = n_args; arg >= 1; arg--) { + for(arg = n_args; arg >= 1; arg--) { lua_rawseti(L, 1, arg); } lua_pushinteger(L, n_args); -- cgit v1.2.3 From 0c9ea080152cf2adf57c521e4c8184c595eaf107 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Aug 2016 20:50:56 +0200 Subject: mod_c2s: Fix whitespace (why does it keep getting messed up?) --- plugins/mod_c2s.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index e69bf461..71da8773 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -246,9 +246,9 @@ function listener.onconnect(conn) function session.data(data) -- Parse the data, which will store stanzas in session.pending_stanzas if data then - data = filter("bytes/in", data); - if data then - local ok, err = stream:feed(data); + data = filter("bytes/in", data); + if data then + local ok, err = stream:feed(data); if not ok then log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); session:close("not-well-formed"); -- cgit v1.2.3 From 8631e529ba01d20a36f451029c450d97ef5c07af Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Aug 2016 20:51:34 +0200 Subject: mod_c2s: Don't try to keep alive sessions where the stream is not (yet) open --- plugins/mod_c2s.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 71da8773..1b5dd91a 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -294,7 +294,10 @@ function listener.onreadtimeout(conn) end local function keepalive(event) - return event.session.send(' '); + local session = event.session; + if not session.notopen then + return event.session.send(' '); + end end function listener.associate_session(conn, session) -- cgit v1.2.3 From 3506b088471128c7579c11782dff473223f49579 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 8 Aug 2016 16:07:46 +0200 Subject: net.http.server: Set blocksize for serving data from FDs to 64k (sweet spot of efficiency according to a recent study) --- net/http/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/http/server.lua b/net/http/server.lua index bc39767f..ba45ede0 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -13,7 +13,7 @@ local traceback = debug.traceback; local tostring = tostring; local cache = require "util.cache"; local codes = require "net.http.codes"; -local blocksize = require "socket".BLOCKSIZE or 2048; +local blocksize = 2^16; local _M = {}; -- cgit v1.2.3