mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
[prosody.git] / plugins / mod_bosh.lua
index 5de79eff187c4580ab88a5322a30991102b3a57c..bc31b3a13c8140de5424763277d4bfbd20b57628 100644 (file)
@@ -254,7 +254,7 @@ function stream_callbacks.handlestanza(request, stanza)
                if stanza.attr.xmlns == xmlns_bosh then
                        stanza.attr.xmlns = "jabber:client";
                end
-               session.ip = request.handler.ip();
+               session.ip = request.handler:ip();
                core_process_stanza(session, stanza);
        end
 end
@@ -298,7 +298,14 @@ function on_timer()
        end
 end
 
-local ports = module:get_option("bosh_ports") or { 5280 };
-httpserver.new_from_config(ports, handle_request, { base = "http-bind" });
 
-server.addtimer(on_timer);
+local function setup()
+       local ports = module:get_option("bosh_ports") or { 5280 };
+       httpserver.new_from_config(ports, handle_request, { base = "http-bind" });
+       server.addtimer(on_timer);
+end
+if prosody.start_time then -- already started
+       setup();
+else
+       prosody.events.add_handler("server-started", setup);
+end