# HG changeset patch # User jbe # Date 1434760420 -7200 # Node ID 4e72725118d0b156996739a6d2fe1ee7e238629e # Parent 40a7bd08e304943e037f41dba7935b9d1d14cce0 Added drain_timeout to HTTP module diff -r 40a7bd08e304 -r 4e72725118d0 moonbridge_http.lua --- a/moonbridge_http.lua Sat Jun 20 01:26:30 2015 +0200 +++ b/moonbridge_http.lua Sat Jun 20 02:33:40 2015 +0200 @@ -199,8 +199,8 @@ local body_size_limit = options.body_size_limit or 64*1024*1024 local request_idle_timeout = default("request_idle_timeout", 65) local request_header_timeout = default("request_header_timeout", 30) - local request_body_timeout = default("request_body_timeout", 300) local response_timeout = default("response_timeout", 1800) + local drain_timeout = default("drain_timeout", 2) local poll = options.poll_function or moonbridge_io.poll -- return socket handler: return function(socket) @@ -226,8 +226,19 @@ end -- function that enforces consumption of all input: local function consume_all() + local endtime + if consume == drain then + -- do not consume endlessly for the sole purpose to drain + endtime = moonbridge_io.timeref() + drain_timeout + end while consume do - poll(socket_set, nil) + if endtime then + if not poll(socket_set, nil, 0-moonbridge_io.timeref(endtime)) then + break + end + else + poll(socket_set, nil) + end consume() end end