From: Azat Khuzhin Date: Sun, 3 Feb 2019 15:47:14 +0000 (+0300) Subject: test/ssl/bufferevent_wm: explicitly break the loop once client/server received enough X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae9b285d2d7c9b898049072c157d50769d8014ea;p=libevent test/ssl/bufferevent_wm: explicitly break the loop once client/server received enough There can be tricky cases (that can be reproduced by reducing SO_RCVBUF/SO_SNDBUF to 6144, on linux, and be aware, since linux doubles this const), when there is still write event pending, although we read enough. This should be fixed in a more sophisticated way, but to backport the patch, let's simply break the loop manually. The ssl/bufferevent_wm originally failed on solaris. --- diff --git a/test/regress_ssl.c b/test/regress_ssl.c index b486b803..68c28114 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -806,6 +806,7 @@ struct wm_context size_t limit; size_t get; struct bufferevent *bev; + struct wm_context *neighbour; }; static void wm_transfer(struct bufferevent *bev, void *arg) @@ -821,6 +822,9 @@ wm_transfer(struct bufferevent *bev, void *arg) ctx->server ? "server" : "client", bev)); bufferevent_setcb(bev, NULL, NULL, NULL, NULL); bufferevent_disable(bev, EV_READ); + if (ctx->neighbour->get >= ctx->neighbour->limit) { + event_base_loopbreak(bufferevent_get_base(bev)); + } } else { ctx->get += drain; evbuffer_drain(in, drain); @@ -953,6 +957,9 @@ regress_bufferevent_openssl_wm(void *arg) tt_assert(bev); client.bev = bev; + server.neighbour = &client; + client.neighbour = &server; + bufferevent_setwatermark(bev, EV_READ, 0, client.wm_high); bufferevent_setcb(bev, wm_transfer, NULL, wm_eventcb, &client);