Changeset

1062:f9a1ac50782b

mod_posix: Fix calls to log() (replace with module:log) and make some global accesses explicit
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Apr 2009 21:35:24 +0100
parents 1061:8c5876378c6f
children 1063:b873715ffd96
files plugins/mod_posix.lua
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_posix.lua	Thu Apr 23 21:34:03 2009 +0100
+++ b/plugins/mod_posix.lua	Thu Apr 23 21:35:24 2009 +0100
@@ -6,7 +6,7 @@
 
 local signal = select(2, pcall(require, "util.signal"));
 if type(signal) == "string" then
-	log("warn", "Couldn't load signal library, won't respond to SIGTERM");
+	module:log("warn", "Couldn't load signal library, won't respond to SIGTERM");
 end
 
 local config_get = require "core.configmanager".get;
@@ -27,11 +27,11 @@
 	if pidfile_written then
 		remove_pidfile();
 	end
-	local pidfile = config.get("*", "core", "pidfile");
+	local pidfile = config_get("*", "core", "pidfile");
 	if pidfile then
 		local pf, err = io.open(pidfile, "w+");
 		if not pf then
-			log("error", "Couldn't write pidfile; %s", err);
+			module:log("error", "Couldn't write pidfile; %s", err);
 		else
 			pf:write(tostring(pposix.getpid()));
 			pf:close();
@@ -61,11 +61,11 @@
 	local function daemonize_server()
 		local ok, ret = pposix.daemonize();
 		if not ok then
-			log("error", "Failed to daemonize: %s", ret);
+			module:log("error", "Failed to daemonize: %s", ret);
 		elseif ret and ret > 0 then
 			os.exit(0);
 		else
-			log("info", "Successfully daemonized to PID %d", pposix.getpid());
+			module:log("info", "Successfully daemonized to PID %d", pposix.getpid());
 			write_pidfile();
 		end
 	end
@@ -80,13 +80,13 @@
 -- Set signal handler
 if signal.signal then
 	signal.signal("SIGTERM", function ()
-		log("warn", "Received SIGTERM...");
-		unlock_globals();
-		if prosody_shutdown then
-			prosody_shutdown("Received SIGTERM");
+		module:log("warn", "Received SIGTERM...");
+		_G.unlock_globals();
+		if _G.prosody_shutdown then
+			_G.prosody_shutdown("Received SIGTERM");
 		else
-			log("warn", "...no prosody_shutdown(), ignoring.");
+			module:log("warn", "...no prosody_shutdown(), ignoring.");
 		end
-		lock_globals();
+		_G.lock_globals();
 	end);
 end