]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Fixed hang occurring when nested ioloops are used in response callb...
authorStephan Bosch <stephan@dovecot.fi>
Tue, 13 Sep 2016 20:54:02 +0000 (22:54 +0200)
committerStephan Bosch <stephan@dovecot.fi>
Tue, 13 Sep 2016 21:15:27 +0000 (23:15 +0200)
To prevent missing disconnect events, i_stream_read() is called once a change in ioloop is detected.
However, if something was actually read into the stream, the input handler was never called.
So, a response could linger in the stream buffer, without being handled, thereby causing the connection to hang indefinitely.
An additional input event could end the hang, but sometimes this doesn't happen before the request times out.

This problem was seen in test-http-payload once in about 10 invocations.
Obox uses nested ioloops, to this applies there.

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

index b24964a2ffe2b11e4078f5d9bd6ba18a5b195f3e..05a866a61fea99a4fa52553a289b61cbc0c13261 100644 (file)
@@ -282,6 +282,10 @@ int http_client_connection_check_ready(struct http_client_connection *conn)
                                                "EOF"));
                        return -1;
                }
+
+               /* we may have read some data */
+               if (i_stream_get_data_size(conn->conn.input) > 0)
+                       i_stream_set_input_pending(conn->conn.input, TRUE);
        }
        return 1;
 }