From 25ddbd7f566e7ea55e64c8e2afed576814b4cb69 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 5 Oct 2017 15:52:28 -0700 Subject: [PATCH] Make keepAliveRelease consistent between EventBase and VirtualEventBase Summary: [Folly] Make `keepAliveRelease` consistent between `EventBase` and `VirtualEventBase`. Reviewed By: elsteveogrande Differential Revision: D5982132 fbshipit-source-id: 536d48e5672567e78786691bfb283c34d1f31960 --- folly/io/async/EventBase.h | 7 +++---- folly/io/async/VirtualEventBase.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 9df03523..fff75adb 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -654,11 +654,10 @@ class EventBase : private boost::noncopyable, } void keepAliveRelease() override { - if (inRunningEventBaseThread()) { - loopKeepAliveCount_--; - } else { - add([=] { loopKeepAliveCount_--; }); + if (!inRunningEventBaseThread()) { + return add([=] { keepAliveRelease(); }); } + loopKeepAliveCount_--; } private: diff --git a/folly/io/async/VirtualEventBase.h b/folly/io/async/VirtualEventBase.h index 426bd8a2..ebf928aa 100644 --- a/folly/io/async/VirtualEventBase.h +++ b/folly/io/async/VirtualEventBase.h @@ -140,8 +140,8 @@ class VirtualEventBase : public folly::Executor, public folly::TimeoutManager { } void keepAliveRelease() override { - if (!getEventBase().inRunningEventBaseThread()) { - return getEventBase().add([=] { keepAliveRelease(); }); + if (!inRunningEventBaseThread()) { + return add([=] { keepAliveRelease(); }); } if (loopKeepAliveCountAtomic_.load()) { loopKeepAliveCount_ += loopKeepAliveCountAtomic_.exchange(0); -- 2.34.1