-
Notifications
You must be signed in to change notification settings - Fork 38.6k
re-work Shutdown() function #1439
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
|
I appreciate that you're trying to improve the naming, but be careful that this does change behaviour in the case of bitcoind. Previously, QueueShutdown (in non-ui context) started Shutdown in a new thread, to make sure that execution returns immediately. This means that an RPC command such as "quit" got the chance to return a reply. It now calls Shutdown directly, which shuts down bitcoin in the current thread and then exit()s. |
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.
I don't like the name "FinishShutdown" much. This is not finishing the shutdown, it is the only real shutdown functionality, the other functions are just queuing it to happen.
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.
If we call Shutdown() Start- or InitShutdown() this can be Shutdown() again, which would be fine then.
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.
Yes, that's much more clear
|
@laanwj Updated to reflect your suggestions. Can you explain, why noui.cpp is not added in bitcoin-qt.pro? I found it quite strange to not be able to edit that file directly somehow. |
|
Looks good now. Well, it used to be that noui.cpp conflicted with some functions in the UI. If this is no longer the case due to using boost::signals now, it could be added in bitcoin-qt.pro too... (or otherwise you could add it under "other" files) |
|
Fine and at least on my local build it compiles just fine with noui.cpp added to the .pro. Could you verify, if this would break the official Gitian build process before I update the pull? |
|
I'm unable to test gitian right now. Maybe it's better to leave that for another (more trivial) pull. Focus this one on shutdown functionality, this is quite a big fish to fry, and needs heavy testing. |
|
Okay, so let's see what other devs think. |
|
BTW, does this solve the original issue with exit() in Shutdown? I don't see it in the diff. |
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.
This and the previous change do not compile.
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.
Ah I missed that, because it's in an #ifdef, which my compiler ignores, because I compile the GUI version. It should be a Shutdown(NULL).
|
If the one non-compiling change is reverted, ACK |
|
I'm asking myself, if the change in net.cpp is correct, but as net.cpp is used by the Qt version and bitcoind it should be a StartShutdown() call. @TheBlueMatt I reverted the changes that don't compile, they now use @laanwj The |
|
ACK |
|
@TheBlueMatt One last thing that bothers me, should the 2 |
|
No, in those two cases, shutdown needs to happen immediately, so launching a shutdown thread instead could cause errors. |
|
Understood, thanks :). |
|
@Diapolo ok, that's also a possibility, as it appears that nothing else can "fall through" to there |
|
It does create another issue, though: the icon disappears before the shutdown starts, instead of after it ends. That's one of the things we were trying to prevent. It's useful to keep the icon until the program actually exits, to tell the user that something is running. |
|
@laanwj Seems rather hard to ensure a clean shutdown and wanting to keep the tray-icon till the very end. Leaving the Qt Shutdown(NULL) were it was before leads to killing Qt objects. this looks much more sane now. So any further idea (perhaps in another pull if this requires additional re-work on the GUI)? |
|
Perhaps move the Shutdown() back to where it was and re-add the #ifdef QT_GUI around the exit() in Shutdown(). This would make Bitcoin-Qt exit via the last return 0 in bitcoin.cpp. |
|
Yeah - IMO, the idea to not call exit() at the end of the Shutdown() function in the case of the UI was good. This allows it to wind things down afterward instead of before. Edit: or even better: make it explicit and save an #ifdef. Create a ShutdownAndExit() function that shuts down and exits (calls Shutdown then exit), and a normal Shutdown() that just shuts down, then use each one at the appropriate place. |
|
@laanwj I see 2 problems with your last suggestion.
|
|
Updated to ensure tray-icon is kept until Bitcoin-Qt exits, no further changes for no UI client. |
|
Well, it ended up with more ifdefs than I thought it would need, but it still looks better than it was imho, ACK. |
src/qt/bitcoin.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.
This comment is no longer needed :)
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.
A final update, which only removes this line was pushed ^^.
|
ACK |
…Shutdown() if no GUI is used and calls uiInterface.QueueShutdown() if a GUI is used / all direct uiInterface.QueueShutdown() calls are replaced with Shutdown() - this ensures a clean GUI shutdown, even when catching a SIGTERM and allows the BitcoinGUI destructor to get called (which fixes a tray-icon issue and keeps the tray-icon until Bitcoin-Qt exits)
|
Note for whoever merges, close #1182, as this fixes it. |
|
I think we should aim to merge this asap, but as this affects critical functionality Gavin or Sipa should probably take a look at it for a sanity check. |
|
ACK on the changes to core; The exit(0) in Shutdown inside ifndef qt is a bit ugly though, imho. |
|
Well, IMO the problem is that "shutdown bitcoin" and "exit program" are essentially different actions. That's why I proposed adding a ShutdownAndExit function, and using that where appropriate: in StartShutdown [ifndef QT_GUI] and AppInit. The name would also clearly signal to the programmer that the function never returns. The normal Shutdown function would shut down bitcoin and return. Diapolo thought it'd be less clear, but I think it'd be better to be explicit. |
re-work Shutdown() function
Add bitcoin SV seeders
0a85445 [Core] Add -debugexclude option (random-zebra) Pull request description: Implemented on top of: - [x] bitcoin#1449 - [x] bitcoin#1437 Backports bitcoin#10123 > setting `-debug` can lead to very noisy debug.logs with subcomponents filling up the log file. See for example https://travis-ci.org/bitcoin/bitcoin/jobs/216767286 where there are hundreds of libevent debug logs. This commit adds an option to exclude certain components from debug logging. The usage is: ``` pivxd -debug -debugexclude=<component1> -debugexclude=<component2> ... ``` This finally reduces spammy logs in the functional tests debug, due to libevent and leveldb (bitcoin#10124 was already included backporting the test suite). ACKs for top commit: furszy: Code looking good, utACK 0a85445 . Fuzzbawls: ACK 0a85445 Tree-SHA512: 6ccbe275ab11f3e1739ed117e49db0a2e56db345287cddc7cc18fc1131d7800d0f08a7e93005f70cf45ed8e340580f91c3017532bd2ea28fedb5735409ae068b
d16b7b2 Buffer log messages and explicitly open logs (random-zebra) Pull request description: implemented on top of - [x] bitcoin#1449 - [x] bitcoin#1437 - [x] bitcoin#1439 Backports bitcoin#6149 > Prevents stomping on debug logs in datadirs that are locked by other instances and lost parameter interaction messages that can get wiped by ShrinkDebugFile(). The log is now opened explicitly and all emitted messages are buffered until this open occurs. The version message and log cut have also been moved to the earliest possible sensible location. ACKs for top commit: furszy: utACK d16b7b2 Fuzzbawls: ACK d16b7b2 Tree-SHA512: f3f859181499661641df1ccf118fdb583517c3f4104313df4c200471436e2c456bd9d15164215cfde274b235afdd2afe19a186c214d3c06461f0e3a03bd944b8
f66e50e [Doc] Add logging RPC to release notes (random-zebra) bf55911 allow libevent logging to be updated during runtime (random-zebra) ec43b51 Set BCLog::LIBEVENT correctly for old libevent versions. (random-zebra) cbaf724 [rpc] Add logging rpc (random-zebra) Pull request description: Implemented on top of: - [x] bitcoin#1449 - [x] bitcoin#1437 - [x] bitcoin#1439 - [x] bitcoin#1450 Backports bitcoin#10150 > Adds an RPC to get/set active logging categories. First commit allows all categories except libevent to be reconfigured during runtime. Second commit modifies InitHTTPServer() to allow leveldb logging to be reconfigured during runtime. ACKs for top commit: furszy: Really nice 👍 , ACK f66e50e . Fuzzbawls: ACK f66e50e Tree-SHA512: 7b735628d341fb8661eb76f57dadc78e69ea63c62edb778450b3d9e3b7137ce06e08ceab835967b923401a9687e5b2605722a9f256e6ed85fc372a0e46086b8f
882ef90 [Doc] Update release notes for `-debuglogfile` (random-zebra) 3d5ad7f test: Add tests for `-debuglogfile` with subdirs (random-zebra) 2c2e36d test: Add test for `-debuglogfile` (random-zebra) b44a324 Add `-debuglogfile` option (random-zebra) Pull request description: Implemented on top of - [x] bitcoin#1449 - [x] bitcoin#1437 - [x] bitcoin#1439 - [x] bitcoin#1450 - [x] bitcoin#1451 Only last 4 commits are relevant to this PR. Backports bitcoin#11781 > This patch adds an option to configure the name and/or directory of the debug log file.</br></br> The user can specify either a relative path, in which case the path is relative to the (network specific) data directory. They can also specify an absolute path to put the log anywhere else in the file system. Functional test included. ACKs for top commit: Fuzzbawls: ACK 882ef90 furszy: utACK 882ef90 Tree-SHA512: 02a0e6487683e5111765af7296ef7ce035372febf037268d99d29b4c4a2f74bcc40f46a0f5b1bacddc2249c2a7e40255555e83ca9d51bf71d9e054c6e85765cc
5c8e968 [Trivial] Document logtimemicros flag in the help (random-zebra) 4daa10a util: Store debug log file path in BCLog::Logger member. (random-zebra) 2f03e85 scripted-diff: Rename BCLog::Logger member variables. (random-zebra) 303700e util: Refactor GetLogCategory. (random-zebra) 0ae18c0 util: Encapsulate logCategories within BCLog::Logger. (random-zebra) a2fb3fd util: Move debug file management functions into Logger. (random-zebra) 5a42d82 util: Establish global logger object. (random-zebra) 15c0da4 [Refactor] Complete boost::filesystem namespace in util (random-zebra) 81ddbf4 MOVEONLY: Move logging code from util.{h,cpp} to new files. (random-zebra) Pull request description: Implemented on top of: - [x] bitcoin#1449 - [x] bitcoin#1437 - [x] bitcoin#1439 - [x] bitcoin#1450 - [x] bitcoin#1451 - [x] bitcoin#1455 This creates a new class BCLog::Logger to encapsulate all global logging configuration and state. Adapted from - bitcoin#13021 - bitcoin#12954 ACKs for top commit: Fuzzbawls: ACK 5c8e968 furszy: utACK 5c8e968 Tree-SHA512: 0b10a031dd7e32b48485236fbdd8249d011049e6f99e1df145b7dea4cab9e6e67e19d1bb13ff48e99eb2487a8399bbb8298fe851ad8873416fc1053aee0379bc
This pull is based on a discussion with @TheBlueMatt and @laanwj.
The current implementation (current master branch) sometimes crashes Bitcoin-Qt (bad) and doesn't allow GUI object destructors do their work as we call exit() in Shutdown(), which leads to an unremoved tray-icon (as visible bug).
I'm sure we could remove some
#include "ui_interface.h"in the modified files, but I was not really sure about that, so input is welcome.Fixes: #1182