Commit c429f97d authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Call addTimerFd only after a callback to avoid issuing duplicate poll requests

Summary: Call addTimerFd only after a callback to avoid issuing duplicate poll requests

Reviewed By: danobi

Differential Revision: D20843253

fbshipit-source-id: 9aa538dcc4cc63f1d1a3431d41366ce3fa3644cb
parent 4dc81d1a
...@@ -187,7 +187,9 @@ void PollIoBackend::scheduleTimeout() { ...@@ -187,7 +187,9 @@ void PollIoBackend::scheduleTimeout() {
scheduleTimeout(std::chrono::microseconds(0)); // disable scheduleTimeout(std::chrono::microseconds(0)); // disable
} }
addTimerFd(); // we do not call addTimerFd() here
// since it has to be added only once, after
// we process a poll callback
} }
void PollIoBackend::scheduleTimeout(const std::chrono::microseconds& us) { void PollIoBackend::scheduleTimeout(const std::chrono::microseconds& us) {
...@@ -468,6 +470,10 @@ int PollIoBackend::eb_event_base_loop(int flags) { ...@@ -468,6 +470,10 @@ int PollIoBackend::eb_event_base_loop(int flags) {
size_t numProcessedTimers = 0; size_t numProcessedTimers = 0;
// save the processTimers_
// this means we've received a notification
// and we need to add the timer fd back
bool processTimersFlag = processTimers_;
if (processTimers_ && !loopBreak_) { if (processTimers_ && !loopBreak_) {
numProcessedTimers = processTimers(); numProcessedTimers = processTimers();
processTimers_ = false; processTimers_ = false;
...@@ -495,6 +501,10 @@ int PollIoBackend::eb_event_base_loop(int flags) { ...@@ -495,6 +501,10 @@ int PollIoBackend::eb_event_base_loop(int flags) {
(flags & EVLOOP_ONCE)) { (flags & EVLOOP_ONCE)) {
done = true; done = true;
} }
if (processTimersFlag) {
addTimerFd();
}
} }
return 0; return 0;
......
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