From: Stephan Bosch Date: Sun, 19 Jun 2016 23:15:18 +0000 (+0200) Subject: lib-http: server: Wrap request payload in a timeout input stream. X-Git-Tag: 2.3.0.rc1~3472 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f60fe422cdfbf5427938d2829f16505162d9a9ae;p=thirdparty%2Fdovecot%2Fcore.git lib-http: server: Wrap request payload in a timeout input stream. The server cannot reset the timeout properly while the payload is being read by the application. The HTTP client solved this same problem by identical means. --- diff --git a/src/lib-http/http-server-connection.c b/src/lib-http/http-server-connection.c index 4cce93cb9b..2636b9e46a 100644 --- a/src/lib-http/http-server-connection.c +++ b/src/lib-http/http-server-connection.c @@ -6,6 +6,7 @@ #include "str.h" #include "ioloop.h" #include "istream.h" +#include "istream-timeout.h" #include "ostream.h" #include "connection.h" #include "iostream-rawlog.h" @@ -312,6 +313,7 @@ static bool http_server_connection_handle_request(struct http_server_connection *conn, struct http_server_request *req) { + const struct http_server_settings *set = &conn->server->set; struct istream *payload; i_assert(!conn->in_req_callback); @@ -328,7 +330,11 @@ http_server_connection_handle_request(struct http_server_connection *conn, /* wrap the stream to capture the destroy event without destroying the actual payload stream. */ conn->incoming_payload = req->req.payload = - i_stream_create_limit(req->req.payload, (uoff_t)-1); + i_stream_create_timeout(req->req.payload, + set->max_client_idle_time_msecs); + /* we've received the request itself, and we can't reset the + timeout during the payload reading. */ + http_server_connection_timeout_stop(conn); } else { conn->incoming_payload = req->req.payload = i_stream_create_from_data("", 0);