summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2019-01-29 01:09:44 +0300
committerAzat Khuzhin <azat@libevent.org>2019-01-29 01:16:48 +0300
commit30791eccce0a5933acfb5ce0ce77fe1f325bd26e (patch)
treee39b2d704ac9959b752f86d7813b560df13b1f52 /http.c
parentb8ca5a6820882e20b24f723100dfde88417d8bc3 (diff)
downloadlibevent-30791eccce0a5933acfb5ce0ce77fe1f325bd26e.tar.gz
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)
Diffstat (limited to 'http.c')
-rw-r--r--http.c8
1 files changed, 8 insertions, 0 deletions
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 {