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

wait for killfunc completion when shutting down current app #670

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

Conversation

istyf
Copy link
Contributor

@istyf istyf commented Nov 1, 2024

This PR attempts to fix #669 by reworking how the killFunc is signalled that a shutdown has been requested.

Instead of reading directly from e.binStopCh (that creates a data race with the writer) it closes on a returned shutdown channel that is used from a new mutexed e.stopBin() func. The shutdown channel takes a channel of int, where the int is the "exit code" passed back to the requestor. It isn't actually the exit code of the process, but a code that can be (and currently is) used to os.Exit the entire process if shutdown failed.

The atomic.Bool change is unrelated to the actual issue, but was required to be able to run the unit tests with -race to detect if there were any races between all the channels and goroutine handling going on in this code.

Reading through the issue list there is a good possibility that this PR will fix, or considerably reduce, the problems seen in #640 #492 #334 and do away with the need for #131 .

This PR has been unit tested and development tested on wsl2 linux and an Apple M2 MBP.

@xiantang
Copy link
Collaborator

i will take look into this pr. lets see how to make the logic easy to understand

@istyf
Copy link
Contributor Author

istyf commented Dec 17, 2024

@xiantang Great! Let me know if I can be of any help. I suppose I could add a few comments here and there to make the intention more clear.

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.

Wait for complete current app shutdown before starting a new build run
2 participants