]> granicus.if.org Git - libevent/commitdiff
test/ssl/bufferevent_wm: explicitly break the loop once client/server received enough
authorAzat Khuzhin <azat@libevent.org>
Sun, 3 Feb 2019 15:47:14 +0000 (18:47 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sun, 3 Feb 2019 15:51:28 +0000 (18:51 +0300)
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.

test/regress_ssl.c

index b486b803ef423aea20056720ddccad5cf811464c..68c28114f7eaf52fe198d438f3415304260d835a 100644 (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);