]> granicus.if.org Git - libevent/commitdiff
regress_ssl: make ssl/bufferevent_wm_filter more fault-tolerance
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 5 Nov 2018 19:25:15 +0000 (22:25 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Mon, 5 Nov 2018 19:25:15 +0000 (22:25 +0300)
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

index 5b2dce87dd22503506e6b440dfea8c58cb77ebd0..88010a92ad691dc271410da15aab2774adaa25d0 100644 (file)
@@ -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 ", "