Changeset

6665:e923d7cb8430

Merge
author Matthew Wild <mwild1@gmail.com>
date Wed, 06 May 2015 19:21:29 +0100
parents 6664:5466f24e51c9 (current diff) 6658:65563530375b (diff)
children 6666:42fdc8dddf04 6667:e4338c0f739a
files util/events.lua
diffstat 8 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/net/dns.lua	Wed May 06 19:21:18 2015 +0100
+++ b/net/dns.lua	Wed May 06 19:21:29 2015 +0100
@@ -226,7 +226,7 @@
 
 
 function dns.random(...)    -- - - - - - - - - - - - - - - - - - -  dns.random
-	math.randomseed(math.floor(10000*socket.gettime()) % 0x100000000);
+	math.randomseed(math.floor(10000*socket.gettime()) % 0x80000000);
 	dns.random = math.random;
 	return dns.random(...);
 end
--- a/plugins/mod_pubsub/mod_pubsub.lua	Wed May 06 19:21:18 2015 +0100
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Wed May 06 19:21:29 2015 +0100
@@ -125,11 +125,15 @@
 end);
 
 local admin_aff = module:get_option_string("default_admin_affiliation", "owner");
-local function get_affiliation(jid)
+local unowned_aff = module:get_option_string("default_unowned_affiliation");
+local function get_affiliation(jid, node)
 	local bare_jid = jid_bare(jid);
 	if bare_jid == module.host or usermanager.is_admin(bare_jid, module.host) then
 		return admin_aff;
 	end
+	if not node then
+		return unowned_aff;
+	end
 end
 
 function set_service(new_service)
--- a/plugins/mod_s2s/mod_s2s.lua	Wed May 06 19:21:18 2015 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Wed May 06 19:21:29 2015 +0100
@@ -625,8 +625,9 @@
 
 function listener.onreadtimeout(conn)
 	local session = sessions[conn];
+	local host = session.host or session.to_host;
 	if session then
-		return (hosts[session.host] or prosody).events.fire_event("s2s-read-timeout", { session = session });
+		return (hosts[host] or prosody).events.fire_event("s2s-read-timeout", { session = session });
 	end
 end
 
--- a/util-src/encodings.c	Wed May 06 19:21:18 2015 +0100
+++ b/util-src/encodings.c	Wed May 06 19:21:29 2015 +0100
@@ -476,14 +476,15 @@
 static int Lidna_to_ascii(lua_State* L) {	/** idna.to_ascii(s) */
 	size_t len;
 	const char* s = check_utf8(L, 1, &len);
+	char* output = NULL;
+	int ret;
 
 	if(s == NULL || len != strlen(s)) {
 		lua_pushnil(L);
 		return 1; /* TODO return error message */
 	}
 
-	char* output = NULL;
-	int ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES);
+	ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES);
 
 	if(ret == IDNA_SUCCESS) {
 		lua_pushstring(L, output);
--- a/util-src/pposix.c	Wed May 06 19:21:18 2015 +0100
+++ b/util-src/pposix.c	Wed May 06 19:21:29 2015 +0100
@@ -750,7 +750,10 @@
 		lua_pushstring(L, strerror(ret));
 		/* posix_fallocate() can leave a bunch of NULs at the end, so we cut that
 		 * this assumes that offset == length of the file */
-		ftruncate(fileno(f), offset);
+		if(ftruncate(fileno(f), offset) != 0) {
+			lua_pushstring(L, strerror(errno));
+			return 3;
+		}
 		return 2;
 	}
 }
--- a/util/datamanager.lua	Wed May 06 19:21:18 2015 +0100
+++ b/util/datamanager.lua	Wed May 06 19:21:29 2015 +0100
@@ -293,7 +293,7 @@
 
 	local mode, err = lfs.attributes(store_dir, "mode");
 	if not mode then
-		return function() log("debug", err or (store_dir .. " does not exist")) end
+		return function() log("debug", "%s", err or (store_dir .. " does not exist")) end
 	end
 	local next, state = lfs.dir(store_dir);
 	return function(state)
--- a/util/events.lua	Wed May 06 19:21:18 2015 +0100
+++ b/util/events.lua	Wed May 06 19:21:29 2015 +0100
@@ -9,6 +9,7 @@
 
 local pairs = pairs;
 local t_insert = table.insert;
+local t_remove = table.remove;
 local t_sort = table.sort;
 local setmetatable = setmetatable;
 local next = next;
@@ -121,7 +122,7 @@
 		if not w then return; end
 		for i = #w, 1 do
 			if w[i] == wrapper then
-				table.remove(w, i);
+				t_remove(w, i);
 			end
 		end
 		if #w == 0 then
--- a/util/statistics.lua	Wed May 06 19:21:18 2015 +0100
+++ b/util/statistics.lua	Wed May 06 19:21:29 2015 +0100
@@ -88,7 +88,7 @@
 
 			return function (value)
 				n_actual_events = n_actual_events + 1;
-				if n_actual_events%duration_sample_interval > 0 then
+				if n_actual_events%duration_sample_interval == 1 then
 					last_event = (last_event%duration_max_samples) + 1;
 					events[last_event] = value;
 				end
@@ -113,7 +113,7 @@
 
 			return function ()
 				n_actual_events = n_actual_events + 1;
-				if n_actual_events%duration_sample_interval > 0 then
+				if n_actual_events%duration_sample_interval ~= 1 then
 					return nop_function;
 				end