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

prevents a goroutine from being leaked if binary cmd fails to finish #993

Merged
merged 1 commit into from Apr 8, 2021

Conversation

hex0punk
Copy link
Contributor

@hex0punk hex0punk commented Apr 8, 2021

Prevents an egde case where a goroutine would be leaked when the following case executes

		case <-time.After(binaryCmdWaitTimeout):
			log.G(ctx).Errorf("timeout while waiting for binaryIO process to finish. Killing")
			err := b.cmd.Process.Kill()
			if err != nil {
				log.G(ctx).WithError(err).Errorf("error while killing binaryIO process")
			}
		}

If the above occurs before or at the same time as the case below (and the scheduler chooses to the above case), the goroutine above the select block would be leaked as it is blocked by the send to the done channel.

		go func() {
			done <- b.cmd.Wait()
		}()

		select {
		case err := <-done:
			if err != nil {
				log.G(ctx).WithError(err).Errorf("error while waiting for binary cmd to finish")
			}

@hex0punk hex0punk requested a review from a team as a code owner April 8, 2021 08:10
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