changeset 20742:ff4c5d5ee76f

lib-http: client: Fixed hang occurring when nested ioloops are used in response callbacks. 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.
author Stephan Bosch <stephan@dovecot.fi>
date Tue, 13 Sep 2016 22:54:02 +0200
parents 806511128f8c
children b3176b1a9e68
files src/lib-http/http-client-connection.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-http/http-client-connection.c	Sat Sep 10 11:32:28 2016 +0300
+++ b/src/lib-http/http-client-connection.c	Tue Sep 13 22:54:02 2016 +0200
@@ -282,6 +282,10 @@
 						"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;
 }