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

Ignore WAKEUP_TASK in SingleThreadEventExecutor.PollTask #522

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

yyjdelete
Copy link
Contributor

Without this, it may lead to an infinite loop.

@yyjdelete
Copy link
Contributor Author

yyjdelete commented Nov 8, 2019

I didn't find a way to create an test for this. It an concurrency issue and only happen in rare case.

Shutdown will never finished if an task is enqueued during CleanupAndTerminate(). If there is any tasks left, RunAllTasks will return true and call WakeUp(true), and WakeUp(true) will enqueue an WAKEUP_TASK and it makes the next call to RunAllTasks still return true.

while (!this.ConfirmShutdown())
{
this.RunAllTasks(this.preciseBreakoutInterval);
}
this.CleanupAndTerminate(true);

while (true)
{
if (this.ConfirmShutdown())
{
break;
}
}

if (this.RunAllTasks() || this.RunShutdownHooks())
{
if (this.IsShutdown)
{
// Executor shut down - no new tasks anymore.
return true;
}
// There were tasks in the queue. Wait a little bit more until no tasks are queued for the quiet period.
this.WakeUp(true);
return false;
}

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.

1 participant