From: Azat Khuzhin Date: Mon, 28 Jan 2019 22:09:44 +0000 (+0300) Subject: http: try to read existing data in buffer under EVHTTP_CON_READ_ON_WRITE_ERROR X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30791eccce0a5933acfb5ce0ce77fe1f325bd26e;p=libevent http: try to read existing data in buffer under EVHTTP_CON_READ_ON_WRITE_ERROR There are two possible ways of getting response from the server: - processing existing bufferevent buffer - reading from the socket (even after write() errored with -1, it is still possible) But we did not tried the first option, only the second one. Fixes: http/read_on_write_error (on freebsd/osx) --- diff --git a/http.c b/http.c index 4e114b70..3b48a738 100644 --- a/http.c +++ b/http.c @@ -1534,6 +1534,14 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg) return; } + if (what & BEV_EVENT_READING && + evcon->flags & EVHTTP_CON_READ_ON_WRITE_ERROR && + evbuffer_get_length(bufferevent_get_input(bufev))) { + event_deferred_cb_schedule_(get_deferred_queue(evcon), + &evcon->read_more_deferred_cb); + return; + } + evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); } else if (what == BEV_EVENT_CONNECTED) { } else {