Skip to content

Commit

Permalink
Merge pull request #7949 from wjin/fix
Browse files Browse the repository at this point in the history
Event: fix clock skew problem

Reviewed-by: Haomai Wang <haomai@xsky.com>
  • Loading branch information
yuyuyu101 committed Mar 13, 2016
2 parents 2066996 + e904670 commit 497cde4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/msg/async/Event.cc
Expand Up @@ -303,13 +303,9 @@ int EventCenter::process_time_events()
* events to be processed ASAP when this happens: the idea is that
* processing events earlier is less dangerous than delaying them
* indefinitely, and practice suggests it is. */
bool clock_skewed = false;
if (now < last_time) {
map<utime_t, list<TimeEvent> > changed;
for (map<utime_t, list<TimeEvent> >::iterator it = time_events.begin();
it != time_events.end(); ++it) {
changed[utime_t()].swap(it->second);
}
time_events.swap(changed);
clock_skewed = true;
}
last_time = now;

Expand All @@ -318,7 +314,7 @@ int EventCenter::process_time_events()
for (map<utime_t, list<TimeEvent> >::iterator it = time_events.begin();
it != time_events.end(); ) {
prev = it;
if (cur >= it->first) {
if (cur >= it->first || clock_skewed) {
need_process.splice(need_process.end(), it->second);
++it;
time_events.erase(prev);
Expand Down

0 comments on commit 497cde4

Please sign in to comment.