Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue=1251, use clock_gettime(CLOCK_MONOTONIC) to get current time #1252

Merged
merged 4 commits into from
May 11, 2017

Conversation

caijieming-ng
Copy link
Collaborator

@caijieming-ng caijieming-ng commented May 5, 2017

bugfix for system time rollback

@baidubot
Copy link
Collaborator

baidubot commented May 5, 2017

Reviewers: @00k @lylei @yvxiang

@caijieming-ng
Copy link
Collaborator Author

增加单测

int delta = 0;
delta = ts2.tv_sec - tv.tv_sec;
ASSERT_TRUE(-1 <= delta && delta <= 1);
ASSERT_TRUE(ts1.tv_sec < ts2.tv_sec);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts1是MONOTONIC的;
ts2是REALTIME的;
二者不是同一个东东,比较是啥意思。。

Copy link
Collaborator Author

@caijieming-ng caijieming-ng May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第一个断言,想说明gettimeofday和CLOCK_REALTIME两个函数获得的时间是一致的;
第二个断言,说明monotonic函数确实是取了系统启动后的时间,应该恒小于CLOCK_REALTIME

Copy link
Collaborator

@00k 00k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@00k
Copy link
Collaborator

00k commented May 8, 2017

#1251

@taocp
Copy link
Collaborator

taocp commented May 11, 2017

LGTM

@taocp taocp merged commit 6032e59 into baidu:master May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants