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

fix potential overflow of requestId #124

Merged
merged 2 commits into from
Jun 21, 2016
Merged

Conversation

tangdi
Copy link
Contributor

@tangdi tangdi commented Jun 20, 2016

issue description is here.

a long value representing requestId composes of two parts:

  1. higher bits from 63 to 20 is system time millis
  2. lower bits from 19 to 0 is offset count

if offset count equals to 2^20, it will be reset to 0 and the last offset reset time is recorded. If during one millis second, offset count hit max again, it will wait until this millis second passes.

@tangdi tangdi closed this Jun 21, 2016
return System.currentTimeMillis() * 100000 + offset.incrementAndGet();
long currentTime = System.currentTimeMillis();
long count = offset.incrementAndGet();
if(count == MAX_COUNT_PER_MILLIS){
Copy link
Collaborator

Choose a reason for hiding this comment

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

此处需要改为count >= MAX_COUNT_PER_MILLIS

@tangdi tangdi reopened this Jun 21, 2016
@rayzhang0603
Copy link
Collaborator

LGTM

@rayzhang0603 rayzhang0603 merged commit af027d3 into weibocom:master Jun 21, 2016
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.

2 participants