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.
This commit is contained in:
Azat Khuzhin 2019-02-03 18:47:14 +03:00
parent b29207dcee
commit ae9b285d2d
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

View File

@ -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);