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
Use a semaphore or pipe for shutdown notification (skeees, laanwj) #13211
Conversation
Instead of polling, use a semaphore (on WIN32) or a pipe (on POSIX) for shutdown notification. This avoids needing a polling loop in bitcoind.
Oh cool - if you are going to split into platform dependent code - you can post to a pthreads semaphore from a unix signal handler. |
I'm fairly sure none of the pthreads-api is signal safe, at least on all platforms.
We only need to wait for shutdown in one thread, so as I see it that additional complexity is not needed. If it happens to be needed in the future it can be added then. Edit: Travis issue is interesting though: looks like there is a race at shutdown where the HTTP server doesn't get to send back the reply to |
This reverts commit 793667a.
Added a commit that reverts 793667a (#11006) to hopefully make travis pass. Likely, this has to be conditional on libevent version to prevent adding a delay on shutdown in another place while fixing another. Edit: that worked locally, but not on travis- weird. |
Maybe that shutdown is too quick, add 50ms delay? It failed on my machine occasionally |
Adding a fixed delay is never a valid solution. |
Once Line 591 in be27048
|
Closing this for now, I don't think it's that important, the current way works fine. |
Instead of polling, use a semaphore (on WIN32) or a pipe (on POSIX) for shutdown notification. This avoids the need for a polling loop in bitcoind.
Extends #13186.
This does not change the polilng of
ShutdownRequested()
in the GUI. This is more complicated: on POSIX it would be possible to import thepipe[0]
handle into the event loop, and call a handler when a character is detected, on Windows theStartShutdown()
could make a callback that queues a qt signal at the GUI side. But I think that is better left for a later PR.