From: Yedidya Feldblum Date: Thu, 5 Oct 2017 22:52:28 +0000 (-0700) Subject: Make keepAliveRelease consistent between EventBase and VirtualEventBase X-Git-Tag: v2017.10.09.00~7 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=25ddbd7f566e7ea55e64c8e2afed576814b4cb69;p=folly.git 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 --- 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);