muduo icon indicating copy to clipboard operation
muduo copied to clipboard

bug: Timer callbacks may still be invoked even after the timer has been canceled

Open jdx2013519 opened this issue 2 years ago • 1 comments

 callingExpiredTimers_ = true;
 cancelingTimers_.clear();
  for (const Entry& it : expired)
  {
    it.second->run();
  }
  callingExpiredTimers_ = false;

if you cancel the timer in callback, the next timer will still run. so you should try to judge timer if it is in cancelingTimers_ beforn callback

 callingExpiredTimers_ = true;
 cancelingTimers_.clear();
  for (const Entry& it : expired)
  {
// if it is in cancelingtimers
    it.second->run();
  }
  callingExpiredTimers_ = false;

jdx2013519 avatar Mar 15 '23 09:03 jdx2013519

Yes, PRs are welcome.

chenshuo avatar Apr 24 '23 20:04 chenshuo