aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-17 11:56:36 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-17 11:56:36 +0100
commit93fbb53acdb0e7ecd7d8745ca514417b3fde1e6f (patch)
tree49f2b6ce22e89b3107d09da8b238acebc9c11045
parent4af6813db9ffa6dcacd2eb20417ca4667159f9af (diff)
parent95e01d796f994eb9ffcb902b38dd1c17ca7c4c57 (diff)
downloadprosody-93fbb53acdb0e7ecd7d8745ca514417b3fde1e6f.tar.gz
prosody-93fbb53acdb0e7ecd7d8745ca514417b3fde1e6f.zip
Merge with 0.6
-rw-r--r--core/loggingmanager.lua2
-rw-r--r--plugins/mod_bosh.lua45
-rw-r--r--plugins/mod_console.lua5
-rw-r--r--plugins/mod_posix.lua1
4 files changed, 28 insertions, 25 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index b329bf11..3ec696d5 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -33,7 +33,7 @@ _G.log = logger.init("general");
module "loggingmanager"
-- The log config used if none specified in the config file
-local default_logging = { { to = "console" } };
+local default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } };
local default_file_logging = { { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } };
local default_timestamp = "%b %d %H:%M:%S";
-- The actual config loggingmanager is using
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua
index 02f3ce38..b11de6c6 100644
--- a/plugins/mod_bosh.lua
+++ b/plugins/mod_bosh.lua
@@ -63,8 +63,11 @@ function on_destroy_request(request)
local session = sessions[request.sid];
if session then
local requests = session.requests;
- for i,r in pairs(requests) do
- if r == request then requests[i] = nil; break; end
+ for i,r in ipairs(requests) do
+ if r == request then
+ t_remove(requests, i);
+ break;
+ end
end
-- If this session now has no requests open, mark it as inactive
@@ -90,6 +93,8 @@ function handle_request(method, body, request)
--log("debug", "Handling new request %s: %s\n----------", request.id, tostring(body));
request.notopen = true;
request.log = log;
+ request.on_destroy = on_destroy_request;
+
local parser = lxp.new(init_xmlhandlers(request, stream_callbacks), "\1");
parser:parse(body);
@@ -118,14 +123,21 @@ function handle_request(method, body, request)
session.send(resp);
end
- if not request.destroyed and session.bosh_wait then
- request.reply_before = os_time() + session.bosh_wait;
- request.on_destroy = on_destroy_request;
- waiting_requests[request] = true;
+ if not request.destroyed then
+ -- We're keeping this request open, to respond later
+ log("debug", "Have nothing to say, so leaving request unanswered for now");
+ if session.bosh_wait then
+ request.reply_before = os_time() + session.bosh_wait;
+ waiting_requests[request] = true;
+ end
+ if inactive_sessions[session] then
+ -- Session was marked as inactive, since we have
+ -- a request open now, unmark it
+ inactive_sessions[session] = nil;
+ end
end
- log("debug", "Have nothing to say, so leaving request unanswered for now");
- return true;
+ return true; -- Inform httpserver we shall reply later
end
end
@@ -162,7 +174,7 @@ function stream_callbacks.streamopened(request, attr)
-- New session
sid = new_uuid();
- local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid), host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid,
+ local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid,
bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY,
requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream,
dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = request.secure };
@@ -174,11 +186,6 @@ function stream_callbacks.streamopened(request, attr)
function session.send(s)
--log("debug", "Sending BOSH data: %s", tostring(s));
local oldest_request = r[1];
- while oldest_request and oldest_request.destroyed do
- t_remove(r, 1);
- waiting_requests[oldest_request] = nil;
- oldest_request = r[1];
- end
if oldest_request then
log("debug", "We have an open request, so sending on that");
response.body = t_concat{"<body xmlns='http://jabber.org/protocol/httpbind' sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>", tostring(s), "</body>" };
@@ -193,7 +200,6 @@ function stream_callbacks.streamopened(request, attr)
else
log("debug", "Destroying the request now...");
oldest_request:destroy();
- t_remove(r, 1);
end
elseif s ~= "" then
log("debug", "Saved to send buffer because there are %d open requests", #r);
@@ -235,8 +241,9 @@ function stream_callbacks.streamopened(request, attr)
session.log("warn", "rid too large (means a request was lost). Last rid: %d New rid: %s", session.rid, attr.rid);
elseif diff <= 0 then
-- Repeated, ignore
- session.log("debug", "rid repeated (on request %s), ignoring: %d", request.id, session.rid);
+ session.log("debug", "rid repeated (on request %s), ignoring: %s (diff %d)", request.id, session.rid, diff);
request.notopen = nil;
+ request.sid = sid;
t_insert(session.requests, request);
return;
end
@@ -250,12 +257,6 @@ function stream_callbacks.streamopened(request, attr)
return;
end
- -- If session was inactive, make sure it is now marked as not
- if #session.requests == 0 then
- (session.log or log)("debug", "BOSH client now active again at %d", os_time());
- inactive_sessions[session] = nil;
- end
-
if session.notopen then
local features = st.stanza("stream:features");
hosts[session.host].events.fire_event("stream-features", { origin = session, features = features });
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index 4457a2f3..a28ae4b2 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -84,9 +84,10 @@ function console_listener.onincoming(conn, data)
session.env._ = data;
- local chunk, err = loadstring("return "..data);
+ local chunkname = "=console";
+ local chunk, err = loadstring("return "..data, chunkname);
if not chunk then
- chunk, err = loadstring(data);
+ chunk, err = loadstring(data, chunkname);
if not chunk then
err = err:gsub("^%[string .-%]:%d+: ", "");
err = err:gsub("^:%d+: ", "");
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index 5888ae10..c38f7eba 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -82,6 +82,7 @@ local function write_pidfile()
end
pidfile = module:get_option("pidfile");
if pidfile then
+ local err;
local mode = stat(pidfile) and "r+" or "w+";
pidfile_handle, err = io.open(pidfile, mode);
if not pidfile_handle then