Software /
code /
prosody
Changeset
6382:57d23c26039b
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 02 Sep 2014 22:33:11 +0200 |
parents | 6377:50e5aed4eeea (current diff) 6381:9ffd582c65d8 (diff) |
children | 6383:ec8878113907 6384:3f4809d01783 |
files | net/http.lua net/http/server.lua net/server_event.lua net/server_select.lua plugins/mod_admin_telnet.lua plugins/mod_c2s.lua plugins/mod_component.lua plugins/mod_s2s/mod_s2s.lua |
diffstat | 9 files changed, 43 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/net/http.lua Tue Sep 02 22:33:11 2014 +0200 @@ -72,6 +72,10 @@ requests[conn] = nil; end +function listener.ondetach(conn) + requests[conn] = nil; +end + local function request_reader(request, data, err) if not request.parser then local function error_cb(reason)
--- a/net/http/server.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/net/http/server.lua Tue Sep 02 22:33:11 2014 +0200 @@ -142,6 +142,10 @@ sessions[conn] = nil; end +function listener.ondetach(conn) + sessions[conn] = nil; +end + function listener.onincoming(conn, data) sessions[conn]:feed(data); end
--- a/net/server_event.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/net/server_event.lua Tue Sep 02 22:33:11 2014 +0200 @@ -438,9 +438,11 @@ end function interface_mt:setlistener(listener) - self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout, self.onreadtimeout, self.onstatus - = listener.onconnect, listener.ondisconnect, listener.onincoming, - listener.ontimeout, listener.onreadtimeout, listener.onstatus; + self:ondetach(); -- Notify listener that it is no longer responsible for this connection + self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout, + self.onreadtimeout, self.onstatus, self.ondetach + = listener.onconnect, listener.ondisconnect, listener.onincoming, listener.ontimeout, + listener.onreadtimeout, listener.onstatus, listener.ondetach; end -- Stub handlers @@ -460,6 +462,8 @@ end function interface_mt:ondrain() end + function interface_mt:ondetach() + end function interface_mt:onstatus() end end @@ -487,6 +491,7 @@ ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs onreadtimeout = listener.onreadtimeout; -- called when socket inactivity timeout occurs ondrain = listener.ondrain; -- called when writebuffer is empty + ondetach = listener.ondetach; -- called when disassociating this listener from this connection onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS) eventread = false, eventwrite = false, eventclose = false, eventhandshake = false, eventstarthandshake = false; -- event handler
--- a/net/server_select.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/net/server_select.lua Tue Sep 02 22:33:11 2014 +0200 @@ -285,6 +285,7 @@ local disconnect = listeners.ondisconnect local drain = listeners.ondrain local onreadtimeout = listeners.onreadtimeout; + local detach = listeners.ondetach local bufferqueue = { } -- buffer array local bufferqueuelen = 0 -- end of buffer array @@ -316,11 +317,15 @@ handler.onreadtimeout = onreadtimeout; handler.setlistener = function( self, listeners ) + if detach then + detach(self) -- Notify listener that it is no longer responsible for this connection + end dispatch = listeners.onincoming disconnect = listeners.ondisconnect status = listeners.onstatus drain = listeners.ondrain handler.onreadtimeout = listeners.onreadtimeout + detach = listeners.ondetach end handler.getstats = function( ) return readtraffic, sendtraffic
--- a/plugins/mod_admin_telnet.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/plugins/mod_admin_telnet.lua Tue Sep 02 22:33:11 2014 +0200 @@ -170,6 +170,10 @@ end end +function console_listener.ondetach(conn) + sessions[conn] = nil; +end + -- Console commands -- -- These are simple commands, not valid standalone in Lua
--- a/plugins/mod_c2s.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/plugins/mod_c2s.lua Tue Sep 02 22:33:11 2014 +0200 @@ -240,9 +240,9 @@ function session.data(data) -- Parse the data, which will store stanzas in session.pending_stanzas if data then - data = filter("bytes/in", data); - if data then - local ok, err = stream:feed(data); + data = filter("bytes/in", data); + if data then + local ok, err = stream:feed(data); if not ok then log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); session:close("not-well-formed");
--- a/plugins/mod_component.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/plugins/mod_component.lua Tue Sep 02 22:33:11 2014 +0200 @@ -317,6 +317,10 @@ end end +function listener.ondetach(conn) + sessions[conn] = nil; +end + module:provides("net", { name = "component"; private = true;
--- a/plugins/mod_net_multiplex.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/plugins/mod_net_multiplex.lua Tue Sep 02 22:33:11 2014 +0200 @@ -34,7 +34,6 @@ function listener.onincoming(conn, data) if not data then return; end local buf = buffers[conn]; - buffers[conn] = nil; buf = buf and buf..data or data; for service, multiplex_pattern in pairs(available_services) do if buf:match(multiplex_pattern) then @@ -57,6 +56,8 @@ buffers[conn] = nil; -- warn if no buffer? end +listener.ondetach = listener.ondisconnect; + module:provides("net", { name = "multiplex"; config_prefix = "";
--- a/plugins/mod_s2s/mod_s2s.lua Tue Sep 02 17:58:12 2014 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Tue Sep 02 22:33:11 2014 +0200 @@ -350,8 +350,11 @@ session.notopen = nil; elseif session.direction == "outgoing" then session.notopen = nil; - -- If we are just using the connection for verifying dialback keys, we won't try and auth it - if not attr.id then error("stream response did not give us a streamid!!!"); end + if not attr.id then + log("error", "Stream response did not give us a stream id!"); + session:close({ condition = "undefined-condition", text = "Missing stream ID" }); + return; + end session.streamid = attr.id; if session.secure and not session.cert_chain_status then @@ -617,6 +620,10 @@ initialize_session(session); end +function listener.ondetach(conn) + sessions[conn] = nil; +end + function check_auth_policy(event) local host, session = event.host, event.session; local must_secure = secure_auth;