]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: server: Wrap request payload in a timeout input stream.
authorStephan Bosch <stephan@dovecot.fi>
Sun, 19 Jun 2016 23:15:18 +0000 (01:15 +0200)
committerStephan Bosch <stephan@dovecot.fi>
Mon, 20 Jun 2016 00:31:22 +0000 (02:31 +0200)
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.

src/lib-http/http-server-connection.c

index 4cce93cb9b4a84b7328a521662d628f97c86fd11..2636b9e46a94e003bee37c11fd477498d0ac8612 100644 (file)
@@ -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);