Make keepAliveRelease consistent between EventBase and VirtualEventBase
authorYedidya Feldblum <yfeldblum@fb.com>
Thu, 5 Oct 2017 22:52:28 +0000 (15:52 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 5 Oct 2017 23:10:29 +0000 (16:10 -0700)
Summary: [Folly] Make `keepAliveRelease` consistent between `EventBase` and `VirtualEventBase`.

Reviewed By: elsteveogrande

Differential Revision: D5982132

fbshipit-source-id: 536d48e5672567e78786691bfb283c34d1f31960

folly/io/async/EventBase.h
folly/io/async/VirtualEventBase.h

index 9df035235a7d60946a28c014cf239c55728edbf5..fff75adb00527d7938c528a07b4894ff4d730ef5 100644 (file)
@@ -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:
index 426bd8a2ced9a78bf797fec402288ee5433772ac..ebf928aa6fc767401a616139e66df05595425042 100644 (file)
@@ -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);