Skip to content

Commit

Permalink
lib-http: client: Fixed hang occurring when nested ioloops are used i…
Browse files Browse the repository at this point in the history
…n 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.
  • Loading branch information
stephanbosch committed Sep 13, 2016
1 parent 0873f75 commit 1c9f4c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib-http/http-client-connection.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1c9f4c1

Please sign in to comment.