X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=net%2Fhttp%2Fserver.lua;h=87d82418550489b2e9955abd3a98572ca7008e43;hb=2c2cf38d1ac841f960da7d36f71fed1d1750ac3f;hp=7cf250098ad7f43b92feb3595c0e4ab8975ddc6d;hpb=99b003b1917a8ab0b561f7fb98d28d1fad8f8dc8;p=prosody.git 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 "");