Commit aa7f8dcd authored by Pingjia Shan's avatar Pingjia Shan Committed by Facebook Github Bot

get rid of redundant calls to RequestContext::saveContext()

Summary:
In the past, these calls were required.

Used to solve static destruction ordering issue.  Any static object that uses RequestContext must call this function in its constructor.

That is when we were using `static folly::ThreadLocal<std::shared_ptr<RequestContext>>`, which was non-leaky.

The problem being addressed is when we have some code of the form:

```lang=c++
void doWork() {
  static EventBase eb;
}
```

But now we are using `SingletonThreadLocal<std::shared_ptr<RequestContext>>`, which is leaky.

So the issue that these calls were there to address seems to have been resolved.

Reviewed By: yfeldblum

Differential Revision: D6332597

fbshipit-source-id: c6aba6620ef2fb3a344ea20f56c8b9c0cdf42c70
parent 13cc05ea
......@@ -33,7 +33,6 @@ AsyncTimeout::AsyncTimeout(TimeoutManager* timeoutManager)
timeoutManager_->attachTimeoutManager(
this,
TimeoutManager::InternalEnum::NORMAL);
RequestContext::saveContext();
}
AsyncTimeout::AsyncTimeout(EventBase* eventBase)
......@@ -47,7 +46,6 @@ AsyncTimeout::AsyncTimeout(EventBase* eventBase)
this,
TimeoutManager::InternalEnum::NORMAL);
}
RequestContext::saveContext();
}
AsyncTimeout::AsyncTimeout(TimeoutManager* timeoutManager,
......@@ -58,7 +56,6 @@ AsyncTimeout::AsyncTimeout(TimeoutManager* timeoutManager,
&event_, -1, EV_TIMEOUT, &AsyncTimeout::libeventCallback, this);
event_.ev_base = nullptr;
timeoutManager_->attachTimeoutManager(this, internal);
RequestContext::saveContext();
}
AsyncTimeout::AsyncTimeout(EventBase* eventBase, InternalEnum internal)
......@@ -68,14 +65,12 @@ AsyncTimeout::AsyncTimeout(EventBase* eventBase, InternalEnum internal)
&event_, -1, EV_TIMEOUT, &AsyncTimeout::libeventCallback, this);
event_.ev_base = nullptr;
timeoutManager_->attachTimeoutManager(this, internal);
RequestContext::saveContext();
}
AsyncTimeout::AsyncTimeout(): timeoutManager_(nullptr) {
folly_event_set(
&event_, -1, EV_TIMEOUT, &AsyncTimeout::libeventCallback, this);
event_.ev_base = nullptr;
RequestContext::saveContext();
}
AsyncTimeout::~AsyncTimeout() {
......
......@@ -114,7 +114,6 @@ EventBase::EventBase(bool enableTimeMeasurement)
}
VLOG(5) << "EventBase(): Created.";
initNotificationQueue();
RequestContext::saveContext();
}
// takes ownership of the event_base
......@@ -140,7 +139,6 @@ EventBase::EventBase(event_base* evb, bool enableTimeMeasurement)
throw std::invalid_argument("EventBase(): event base cannot be nullptr");
}
initNotificationQueue();
RequestContext::saveContext();
}
EventBase::~EventBase() {
......
......@@ -266,8 +266,6 @@ class NotificationQueue {
pid_(pid_t(getpid())),
queue_() {
RequestContext::saveContext();
#ifdef FOLLY_HAVE_EVENTFD
if (fdType == FdType::EVENTFD) {
eventfd_ = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment