diff options
-rw-r--r-- | makefile | 18 | ||||
-rw-r--r-- | net/server_epoll.lua | 22 | ||||
-rw-r--r-- | plugins/mod_c2s.lua | 5 | ||||
-rwxr-xr-x | prosodyctl | 2 |
4 files changed, 34 insertions, 13 deletions
@@ -90,12 +90,12 @@ prosody.cfg.lua.install: prosody.cfg.lua.dist sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > $@ prosody.version: - test -f prosody.release && \ - cp prosody.release $@ || \ - test -f .hg_archival.txt && \ - sed -n 's/^node: \(............\).*/\1/p' .hg_archival.txt > $@ || \ - test -f .hg/dirstate && \ - hexdump -n6 -e'6/1 "%02x"' .hg/dirstate > $@ || \ - echo unknown > $@ - - + if [ -f prosody.release ]; then \ + cp prosody.release $@; \ + elif [ -f .hg_archival.txt ]; then \ + sed -n 's/^node: \(............\).*/\1/p' .hg_archival.txt > $@; \ + elif [ -f .hg/dirstate ]; then \ + hexdump -n6 -e'6/1 "%02x"' .hg/dirstate > $@; \ + else \ + echo unknown > $@; \ + fi diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 53a67dd5..c47e1a70 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -58,6 +58,9 @@ local default_config = { __index = { -- Maximum and minimum amount of time to sleep waiting for events (adjusted for pending timers) max_wait = 86400; min_wait = 1e-06; + + --- How long to wait after getting the shutdown signal before forcefully tearing down every socket + shutdown_deadline = 5; }}; local cfg = default_config.__index; @@ -122,8 +125,8 @@ local function runtimers(next_delay, min_wait) end if readd then - for _, timer in pairs(readd) do - timers:insert(timer, timer[1]); + for id, timer in pairs(readd) do + timers:insert(timer, timer[1], id); end peek = timers:peek(); end @@ -743,6 +746,21 @@ local function setquitting(quit) if quit then quitting = "quitting"; closeall(); + addtimer(1, function () + if quitting then + closeall(); + return 1; + end + end); + if cfg.shutdown_deadline then + addtimer(cfg.shutdown_deadline, function () + if quitting then + for fd, conn in pairs(fds) do -- luacheck: ignore 213/fd + conn:destroy(); + end + end + end); + end else quitting = nil; end diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index f19f9df5..f9c2e9fb 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -108,7 +108,10 @@ function stream_callbacks.streamopened(session, attr) send(features); else (session.log or log)("warn", "No stream features to offer"); - session:close{ condition = "undefined-condition", text = "No stream features to proceed with" }; + session:close({ + condition = "undefined-condition"; + text = "No stream features to proceed with on "..(session.secure and "" or "in").."secure stream"; + }); end end @@ -203,7 +203,7 @@ local function service_command_warning(service_command) if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended"); show_warning(" if Prosody is managed by an init system - use that directly instead."); - lfs = lfs or require + lfs = lfs or require"lfs"; if lfs.attributes("/etc/systemd") then show_warning(" e.g. systemctl %s prosody", service_command); elseif lfs.attributes("/etc/init.d/prosody") then |