aboutsummaryrefslogtreecommitdiffstats
path: root/net/http/server.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-03-10 11:29:47 +0000
committerMatthew Wild <mwild1@gmail.com>2013-03-10 11:29:47 +0000
commit05cd95bf80167c87312b04107a3f2abc25e83094 (patch)
tree479c845b81a7d47465c3223177a7119dbe3dd7ba /net/http/server.lua
parent4c01dc18780c4b0b93616093c86b2c9cff3d12f2 (diff)
parente39fde236178e9d41cf0b1f56aae0aad382df96b (diff)
downloadprosody-05cd95bf80167c87312b04107a3f2abc25e83094.tar.gz
prosody-05cd95bf80167c87312b04107a3f2abc25e83094.zip
Merge 0.9->trunk
Diffstat (limited to 'net/http/server.lua')
-rw-r--r--net/http/server.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index 7cf25009..87d82418 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -89,29 +89,30 @@ function listener.onconnect(conn)
local pending = {};
local waiting = false;
local function process_next()
- --if waiting then log("debug", "can't process_next, waiting"); return; end
- if sessions[conn] and #pending > 0 then
+ if waiting then log("debug", "can't process_next, waiting"); return; end
+ waiting = true;
+ while sessions[conn] and #pending > 0 do
local request = t_remove(pending);
--log("debug", "process_next: %s", request.path);
- waiting = true;
--handle_request(conn, request, process_next);
_1, _2, _3 = conn, request, process_next;
if not xpcall(_handle_request, _traceback_handler) then
conn:write("HTTP/1.0 500 Internal Server Error\r\n\r\n"..events.fire_event("http-error", { code = 500, private_message = last_err }));
conn:close();
end
- else
- --log("debug", "ready for more");
- waiting = false;
end
+ --log("debug", "ready for more");
+ waiting = false;
end
local function success_cb(request)
--log("debug", "success_cb: %s", request.path);
+ if waiting then
+ log("error", "http connection handler is not reentrant: %s", request.path);
+ assert(false, "http connection handler is not reentrant");
+ end
request.secure = secure;
t_insert(pending, request);
- if not waiting then
- process_next();
- end
+ process_next();
end
local function error_cb(err)
log("debug", "error_cb: %s", err or "<nil>");