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 infinite worker loop preventing shutdown when Stop() called #54

Merged
merged 4 commits into from
Jul 11, 2017
Merged

Fix infinite worker loop preventing shutdown when Stop() called #54

merged 4 commits into from
Jul 11, 2017

Conversation

tylerstillwater
Copy link
Contributor

The job fetch routine implements an infinite loop that pulls jobs as long as there are jobs to pull. If a backlog of jobs exists in the queue, and Stop() is called, the worker never terminates. This will cause a program that is attempting to terminate to run indefinitely.

This PR fixes the infinite loop and respects the <-timer.C call in the select loop instead, giving the stopChan and drainChan a chance to fire. Tests are provided to validate this issue is fixed.

In addition, it fixes an issue with a test that hangs indefinitely if it cannot connect to redis.

This PR was, for the most part, already proposed, and much code was taken from that PR. I am submitting this PR to keep my fork in sync as I intend to send additional PRs in the future.

@taylorchu
Copy link
Contributor

lgtm

@taylorchu taylorchu merged commit d3a863d into gocraft:master Jul 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.

3 participants