]> granicus.if.org Git - libevent/commitdiff
http: do not call deferred readcb if readcb is not set
authorAzat Khuzhin <azat@libevent.org>
Sun, 27 Jan 2019 12:16:39 +0000 (15:16 +0300)
committerAzat Khuzhin <azat@libevent.org>
Mon, 28 Jan 2019 19:20:47 +0000 (22:20 +0300)
Otherwise evhttp_read_cb can be called with invalid connection state:
    http/read_on_write_error: [forking] [msg] libevent using: kqueue
      FAIL ../test/regress_http.c:4079: assert(req)
      FAIL ../test/regress_http.c:4087: assert(req)[err] evhttp_read_cb: illegal connection state 0

http.c

diff --git a/http.c b/http.c
index 17d4580435c7fa420c87e8391f5c567c09340a3f..4e114b70a47794911ea7b60b9d9f394f70f2b526 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1171,7 +1171,9 @@ static void
 evhttp_deferred_read_cb(struct event_callback *cb, void *data)
 {
        struct evhttp_connection *evcon = data;
-       evhttp_read_cb(evcon->bufev, evcon);
+       struct bufferevent *bev = evcon->bufev;
+       if (bev->readcb)
+               (bev->readcb)(evcon->bufev, evcon);
 }
 
 static void