-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Split up AppInit2 into multiple phases, daemonize after datadir lock errors #9010
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
Conversation
|
Code Review utACK feaea7001fdec6c0ec5ef6cc1b33cb214131ce25. |
|
ACK. |
|
utACK feaea7001fdec6c0ec5ef6cc1b33cb214131ce25 |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK feaea7001fdec6c0ec5ef6cc1b33cb214131ce25
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason the default value was not assigned in the namespace (like nRelevantServices)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason, will do that.
|
@laanwj I don't think you're setting |
There isn't any parameter interaction based on |
|
@laanwj EDIT: Perhaps the right solution is to remove |
Oh you're right, sorry.
It exists to make running a RPC server optional (disabled by default) with the GUI. I think we should keep that. |
|
Yes I just meant get rid of the variable |
This allows doing some of the steps before e.g. daemonization and some fater.
Before daemonization, just probe the data directory lock and print an
early error message if possible.
After daemonization get the data directory lock again and hold on to it until exit
This creates a slight window for a race condition to happen, however this condition is harmless: it
will at most make us exit without printing a message to console.
$ src/bitcoind -testnet -daemon
Bitcoin server starting
$ src/bitcoind -testnet -daemon
Error: Cannot obtain a lock on data directory /home/orion/.bitcoin/testnet3. Bitcoin Core is probably already running.
There is no need to store this flag globally, the variable is only used inside the initialization process. Thanks to Alex Morcos for the idea.
feaea70 to
deec83f
Compare
Good idea. I pushed these changes:
|
|
ACK deec83f |
Split up AppInit2 into multiple steps: This allows doing some of the steps before daemonization and some later.
To avoid the issue described in #9009 (comment):
Solves #9009:
As for the AppInit2 split: This is something I've been wanting to do for a while. Note that, to reduce risk of regressions, this is just mechanic code movement and doesn't change ordering, besides the
daemon()invocation.Some smarter things could be done such as:
AppInitBasicSetup()toSetupEnvironment()where possible, especially things such as the windows DEP activationInitParameterInteraction()andAppInitParameterInteraction()if/where possible. I'm not sure why this is done in two steps with justAppInitBasicSetup()in between right now.// Variables internal to initialization process only(e.g. an initialization context structure). Some variables there may be completely avoided by moving the code to extract the arguments.ENABLE_WALLETsections fromlibbitcoin_server.a(which contains init.cpp) and remove the circular dependencies (Remaining instances of ENABLE_WALLET inlibbitcoin_server.a#7965)However I do not intend to do these things in this pull.