moonbridge
changeset 201:4e72725118d0
Added drain_timeout to HTTP module
author | jbe |
---|---|
date | Sat Jun 20 02:33:40 2015 +0200 (2015-06-20) |
parents | 40a7bd08e304 |
children | 2ed3d94a0eb7 |
files | moonbridge_http.lua |
line diff
1.1 --- a/moonbridge_http.lua Sat Jun 20 01:26:30 2015 +0200 1.2 +++ b/moonbridge_http.lua Sat Jun 20 02:33:40 2015 +0200 1.3 @@ -199,8 +199,8 @@ 1.4 local body_size_limit = options.body_size_limit or 64*1024*1024 1.5 local request_idle_timeout = default("request_idle_timeout", 65) 1.6 local request_header_timeout = default("request_header_timeout", 30) 1.7 - local request_body_timeout = default("request_body_timeout", 300) 1.8 local response_timeout = default("response_timeout", 1800) 1.9 + local drain_timeout = default("drain_timeout", 2) 1.10 local poll = options.poll_function or moonbridge_io.poll 1.11 -- return socket handler: 1.12 return function(socket) 1.13 @@ -226,8 +226,19 @@ 1.14 end 1.15 -- function that enforces consumption of all input: 1.16 local function consume_all() 1.17 + local endtime 1.18 + if consume == drain then 1.19 + -- do not consume endlessly for the sole purpose to drain 1.20 + endtime = moonbridge_io.timeref() + drain_timeout 1.21 + end 1.22 while consume do 1.23 - poll(socket_set, nil) 1.24 + if endtime then 1.25 + if not poll(socket_set, nil, 0-moonbridge_io.timeref(endtime)) then 1.26 + break 1.27 + end 1.28 + else 1.29 + poll(socket_set, nil) 1.30 + end 1.31 consume() 1.32 end 1.33 end