util.sasl_cyrus: Protect the call to cyrussasl.server_new properly.
[prosody.git] / core / s2smanager.lua
index 0435bea9d098ce215787ebe256564f23bb509a25..f0b802d87e50c164b0e84e9fd7a24a5d6e302178 100644 (file)
@@ -369,11 +369,6 @@ function streamopened(session, attr)
                session.secure = true;
        end
        
-       if session.version >= 1.0 and not (attr.to and attr.from) then
-               (session.log or log)("warn", "Remote of stream "..(session.from_host or "(unknown)").."->"..(session.to_host or "(unknown)")
-                       .." failed to specify to (%s) and/or from (%s) hostname as per RFC", tostring(attr.to), tostring(attr.from));
-       end
-       
        if session.direction == "incoming" then
                -- Send a reply stream header
                session.to_host = attr.to and nameprep(attr.to);
@@ -434,11 +429,8 @@ function streamopened(session, attr)
 end
 
 function streamclosed(session)
-       (session.log or log)("debug", "</stream:stream>");
-       if session.sends2s then
-               session.sends2s("</stream:stream>");
-       end
-       session.notopen = true;
+       (session.log or log)("debug", "Received </stream:stream>");
+       session:close();
 end
 
 function initiate_dialback(session)
@@ -514,6 +506,12 @@ end
 
 local resting_session = { -- Resting, not dead
                destroyed = true;
+               open_stream = function (session)
+                       session.log("debug", "Attempt to open stream on resting session");
+               end;
+               close = function (session)
+                       session.log("debug", "Attempt to close already-closed session");
+               end;
        }; resting_session.__index = resting_session;
 
 function retire_session(session)
@@ -530,6 +528,7 @@ function retire_session(session)
 end
 
 function destroy_session(session, reason)
+       if session.destroyed then return; end
        (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host));
        
        if session.direction == "outgoing" then