Software /
code /
prosody
Comparison
plugins/mod_posix.lua @ 6875:12d68f7b1be0
mod_posix: Detect failure to load util.signal by first pcall return value not by type of the second
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Sep 2015 21:41:11 +0200 |
parent | 6874:e011f289ec77 |
child | 7359:a5a080c12c96 |
child | 7731:a0ee83c4a82c |
comparison
equal
deleted
inserted
replaced
6874:e011f289ec77 | 6875:12d68f7b1be0 |
---|---|
12 local pposix = assert(require "util.pposix"); | 12 local pposix = assert(require "util.pposix"); |
13 if pposix._VERSION ~= want_pposix_version then | 13 if pposix._VERSION ~= want_pposix_version then |
14 module:log("warn", "Unknown version (%s) of binary pposix module, expected %s. Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version); | 14 module:log("warn", "Unknown version (%s) of binary pposix module, expected %s. Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version); |
15 end | 15 end |
16 | 16 |
17 local signal = select(2, pcall(require, "util.signal")); | 17 local have_signal, signal = pcall(require, "util.signal"); |
18 if type(signal) == "string" then | 18 if not have_signal then |
19 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); | 19 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); |
20 end | 20 end |
21 | 21 |
22 local lfs = require "lfs"; | 22 local lfs = require "lfs"; |
23 local stat = lfs.attributes; | 23 local stat = lfs.attributes; |
160 end | 160 end |
161 | 161 |
162 module:hook("server-stopped", remove_pidfile); | 162 module:hook("server-stopped", remove_pidfile); |
163 | 163 |
164 -- Set signal handlers | 164 -- Set signal handlers |
165 if signal.signal then | 165 if have_signal then |
166 signal.signal("SIGTERM", function () | 166 signal.signal("SIGTERM", function () |
167 module:log("warn", "Received SIGTERM"); | 167 module:log("warn", "Received SIGTERM"); |
168 prosody.unlock_globals(); | 168 prosody.unlock_globals(); |
169 prosody.shutdown("Received SIGTERM"); | 169 prosody.shutdown("Received SIGTERM"); |
170 prosody.lock_globals(); | 170 prosody.lock_globals(); |