Can put this up as a pull request on github to review and acceptOn Thu, Jul 23, 2015 at 6:56 PM Bill Vaughan <billvaughan@xxxxxxxxx> wrote:Hi all,I added bufferevent pairs to my project a few weeks ago as it was perfect for what I needed. Got it all working nicely but valgrind was reporting a leak. I finally tracked down the culprit to the bufferevent pair flush code.Here is the patch for libevent 2.0.22. The lock was being taken and not released if the mode was BEV_NORMAL.[bvaughan@dev-client tproxy]$ git diffdiff --git a/libevent-2.0.22-stable/bufferevent_pair.c b/libevent-2.0.22-stable/bufferevent_pair.cindex e9ed9f5..2a77dc7 100644--- a/libevent-2.0.22-stable/bufferevent_pair.c+++ b/libevent-2.0.22-stable/bufferevent_pair.c@@ -284,14 +284,15 @@ be_pair_flush(struct bufferevent *bev, short iotype,Â{    struct bufferevent_pair *bev_p = upcast(bev);    struct bufferevent *partner;-    incref_and_lock(bev);+    if (!bev_p->partner)        return -1;Â-    partner = downcast(bev_p->partner);+  if (mode == BEV_NORMAL)+   Âreturn 0;Â-    if (mode == BEV_NORMAL)-        return 0;+    incref_and_lock(bev);+  partner = downcast(bev_p->partner);    if ((iotype & EV_READ) != 0)        be_pair_transfer(partner, bev, 1);Thanks,-Bill