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

Allow to schedule tasks up to Long.MAX_VALUE #7972

Merged
merged 1 commit into from May 30, 2018
Merged

Conversation

normanmaurer
Copy link
Member

Motivation:

We should allow to schedule tasks with a delay up to Long.MAX_VALUE as we did pre 4.1.25.Final.

Modifications:

Just ensure we not overflow and put the correct max limits in place when schedule a timer. At worse we will get a wakeup to early and then schedule a new timeout.

Result:

Fixes #7970.

@normanmaurer
Copy link
Member Author

@carl-mastrangelo @ejona86 I think this is the correct fix.

@@ -237,7 +236,7 @@ private int epollWait(boolean oldWakeup) throws IOException {
long totalDelay = delayNanos(System.nanoTime());
int delaySeconds = (int) min(totalDelay / 1000000000L, Integer.MAX_VALUE);
return Native.epollWait(epollFd, events, timerFd, delaySeconds,
(int) min(totalDelay - delaySeconds * 1000000000L, Integer.MAX_VALUE));
(int) min(MAX_SCHEDULED_TIMERFD_NS, min(totalDelay - delaySeconds * 1000000000L, Integer.MAX_VALUE)));
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified to drop Integer.MAX_VALUE?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry not sure I understand... what exactly you propose ?

Copy link
Member

Choose a reason for hiding this comment

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

return Native.epollWait(epollFd, events, timerFd, delaySeconds,
    (int) min(MAX_SCHEDULED_TIMERFD_NS, totalDelay - delaySeconds * 1000000000L));

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yeah... let me do this

Copy link
Member Author

Choose a reason for hiding this comment

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

@carl-mastrangelo PTAL again

Motivation:

We should allow to schedule tasks with a delay up to Long.MAX_VALUE as we did pre 4.1.25.Final.

Modifications:

Just ensure we not overflow and put the correct max limits in place when schedule a timer. At worse we will get a wakeup to early and then schedule a new timeout.

Result:

Fixes #7970.
Copy link
Member

@carl-mastrangelo carl-mastrangelo left a comment

Choose a reason for hiding this comment

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

LGTM

@normanmaurer
Copy link
Member Author

@carl-mastrangelo can you validate this one with GRPC as well ?

@normanmaurer normanmaurer self-assigned this May 30, 2018
@normanmaurer normanmaurer merged commit d133bf0 into 4.1 May 30, 2018
@normanmaurer normanmaurer deleted the schedule_delay branch May 30, 2018 09:11
@carl-mastrangelo
Copy link
Member

@normanmaurer I did try to test this out, sadly its pretty time consuming to bring netty into Google if it isn't a released artifact. I think code review is good enough here.

@normanmaurer
Copy link
Member Author

@carl-mastrangelo ok... 😢

@normanmaurer normanmaurer added this to the 4.1.26.Final milestone May 30, 2018
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.

None yet

2 participants