From 9db76151d498844384b41a0f15443af996baf7e2 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 18 Feb 2010 16:22:50 +0000 Subject: modulemanager: Fix traceback on unloading global modules (thanks KSid) --- core/modulemanager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 6b2260f5..1174352b 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -158,7 +158,7 @@ function load(host, module_name, config) log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); end if success then - hosts[host].events.fire_event("module-loaded", { module = module_name, host = host }); + (hosts[api_instance.host] or prosody).events.fire_event("module-loaded", { module = module_name, host = host }); return true; else -- load failed, unloading unload(api_instance.host, module_name); @@ -210,7 +210,7 @@ function unload(host, name, ...) end end modulemap[host][name] = nil; - hosts[host].events.fire_event("module-unloaded", { module = name, host = host }); + (hosts[host] or prosody).events.fire_event("module-unloaded", { module = name, host = host }); return true; end -- cgit v1.2.3 From ec83dc97eea39c0dc3e16eabee81b2fdf1f7bc60 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 18 Feb 2010 16:41:53 +0000 Subject: net.server_event: Pass false as connection error to disconnect handler if close was initiated by us --- net/server_event.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/server_event.lua b/net/server_event.lua index 610c2e7a..3456fb9e 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -262,7 +262,7 @@ do _ = self.eventsession and self.eventsession:close( ) _ = self.eventwritetimeout and self.eventwritetimeout:close( ) _ = self.eventreadtimeout and self.eventreadtimeout:close( ) - _ = self.ondisconnect and self:ondisconnect( self.fatalerror ) -- call ondisconnect listener (wont be the case if handshake failed on connect) + _ = self.ondisconnect and self:ondisconnect( self.fatalerror ~= "client to close" and self.fatalerror) -- call ondisconnect listener (wont be the case if handshake failed on connect) _ = self.conn and self.conn:close( ) -- close connection, must also be called outside of any socket registered events! _ = self._server and self._server:counter(-1); self.eventread, self.eventwrite = nil, nil -- cgit v1.2.3 From f2a5185e0074e220759ccc35ca897d6d948cb219 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 18 Feb 2010 16:44:26 +0000 Subject: net.adns: Don't treat locally-initiated disconnects as fatal with libevent backend in use (thanks Flo) --- net/adns.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/adns.lua b/net/adns.lua index d1876b0f..0121881a 100644 --- a/net/adns.lua +++ b/net/adns.lua @@ -54,13 +54,15 @@ function new_async_socket(sock, resolver) end end function listener.ondisconnect(conn, err) - log("warn", "DNS socket for %s disconnected: %s", peername, err); - local servers = resolver.server; - if resolver.socketset[conn] == resolver.best_server and resolver.best_server == #servers then - log("error", "Exhausted all %d configured DNS servers, next lookup will try %s again", #servers, servers[1]); - end + if err then + log("warn", "DNS socket for %s disconnected: %s", peername, err); + local servers = resolver.server; + if resolver.socketset[conn] == resolver.best_server and resolver.best_server == #servers then + log("error", "Exhausted all %d configured DNS servers, next lookup will try %s again", #servers, servers[1]); + end - resolver:servfail(conn); -- Let the magic commence + resolver:servfail(conn); -- Let the magic commence + end end handler = server.wrapclient(sock, "dns", 53, listener); if not handler then -- cgit v1.2.3