From 54c6fe3c06cb5342130467ecf0f78e3f6d854a36 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 5 Nov 2018 22:25:15 +0300 Subject: [PATCH] regress_ssl: make ssl/bufferevent_wm_filter more fault-tolerance Due to inplace callbacks (i.e. no BEV_OPT_DEFER_CALLBACKS) we cannot be sure that wm_transfer() will not be called recursively and indeed it still happens sometimes, and the referenced patch increase amount of this times, especially for linux/poll. Fixes: 66304a23cf748714159c988e78f35401c5352827 ("Fix ssl/bufferevent_wm_filter when bev does not reach watermark on break") --- test/regress_ssl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/regress_ssl.c b/test/regress_ssl.c index 5b2dce87..88010a92 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -816,16 +816,16 @@ wm_transfer(struct bufferevent *bev, void *arg) size_t len = evbuffer_get_length(in); size_t drain = len < ctx->to_read ? len : ctx->to_read; - if (ctx->get+drain >= ctx->limit) { + if (ctx->get >= ctx->limit) { TT_BLATHER(("wm_transfer-%s(%p): break", ctx->server ? "server" : "client", bev)); bufferevent_setcb(bev, NULL, NULL, NULL, NULL); bufferevent_disable(bev, EV_READ); + } else { + evbuffer_drain(in, drain); + ctx->get += drain; } - evbuffer_drain(in, drain); - ctx->get += drain; - TT_BLATHER(("wm_transfer-%s(%p): " "in: " EV_SIZE_FMT ", " "out: " EV_SIZE_FMT ", " -- 2.40.0