-
Notifications
You must be signed in to change notification settings - Fork 449
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
Client: restore default Event Log settings #3616
Conversation
@CharlieFenton - please check whether the related issue #3606 applies on Mac as well - I don't have the hardware to test either problem or solution. |
Codecov Report
@@ Coverage Diff @@
## master #3616 +/- ##
==========================================
- Coverage 18.11% 18.09% -0.03%
==========================================
Files 107 107
Lines 8787 8803 +16
Branches 1544 1542 -2
==========================================
+ Hits 1592 1593 +1
- Misses 7079 7094 +15
Partials 116 116
|
Yes, this problem is also present on the Mac. This is not an area with which I am most familiar, but I did a quick compare of cc_config.cpp between the 7.14 branch and master, and I think you missed the actual cause of the problem. In both 7.14 and master, LOG_FLAGS:init() sets these three variables: But (although I haven't tested it), I suspect that LOG_FLAGS:init() is never called in master as a result of the changes, because: [2] In 7.14, the first 3 lines of LOG_FLAGS::parse() are: Quite frankly, I've never really understood nor cared for the way these initializers were implemented after being changed from the original |
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 think these proposed changes are unnecessary and that they won't fix this problem. Please see my comment here
Well, my face is a bit red. I incorrectly read the file compare, but I think my analysis still applies. Nonetheless, I think having it in the constructor is still necessary. log_flags.init() is also called in read_config_file() in log_flags.cpp. But If there is no cc_config.xml file, will Note that log_flags.init() is also called in CDlgDiagnosticLogFlags::CDlgDiagnosticLogFlags(), but that is in the manager and so won't affect this issue. |
The observed problem (no default log flags) only occurs at startup when no cc_config.xml is present. That's why experienced users missed it at and before launch - we all have a cc_config.xml file, and for us the client behaved normally. If you subsequently invoke a cc_config.xml file, either by manually reading an existing file, or by using the GUI picker, it behaves normally. It's only the placement of the defaults in the initiator which is failing. My empirical solution is to move the default values into the structure definition, where they do get picked up at initiation, but don't get in the way of subsequent alterations. |
Right. That was due to the removal of the constructor, which called init() even when there was no file to parse (so LOG_FLAGS::parse() was not invoked.) Thanks for the explanation of your approach; I didn't really understand what you are doing; I didn't know you could put initialized variables in a struct declaration. I have a couple of questions, though: |
I can see log_flags.init being called in read_config_file, at This in turn is called from main, at If read_config_file fails to open the file, it bails out quickly, without doing any parsing. But it prints The default values were set by the old, v7.14.2, 'memset' init function. They are not being set by the new, v7.16.5, init function, and the users have noticed. Empirically - but by analogy with the ability to set default values in a SQL |
Well, I've learned something new. Thank you.
Thank you for explaining the cause of the problem (presumably for others who might read this) in more detail than I wrote.
As long as you've tested successfully, I'm OK with it. My preference would still have been to do it in the constructor, because IMO that makes it easier (more obvious) for someone reading the code to see that those 3 variables are being set, and that would have simply reversed the original faulty modification. But I'm comfortable with whatever works. |
@@ -45,11 +45,11 @@ struct LOG_FLAGS { | |||
|
|||
// on by default; intended for all users | |||
// | |||
bool file_xfer; | |||
bool file_xfer = true; |
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.
Currently we're still using VS2010 for Windows release. This code will not work because this type of initialization was added in c++11 only
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.
OK, confirmed. Why didn't somebody say that before? Dug out an ancient copy of Visual Studio Express 2010, and the exact error message is
only static const integral data members can be initialized within a class
Was there any real reason for eliminating memset in this particular function? As I read it, the concern was with clearing complex structures? This one is a simple array of boolean values (fixed length), it's initialised at startup, and released when the program exits. Is that dangerous? If not, why don't we revert here?
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.
memset isn't initialize the members of the structure, it's just initialize a block of memory. I'll look for better solution on this weekend.
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.
The original code is visible in the 7.14 release branch:
LOG_FLAGS::LOG_FLAGS() {
init();
}
void LOG_FLAGS::init() {
memset(this, 0, sizeof(LOG_FLAGS));
// on by default (others are off by default)
//
task = true;
file_xfer = true;
sched_ops = true;
}
The memset sets all to zero, and then the three defaults are set separately.
The replacement in master uses the same default value initialisers, but they are ineffectual.
Closing in favour of #3643, for VS2010 compatibility. |
Fixes #3606
Description of the Change
cc_config.cpp: following discussion in https://boinc.berkeley.edu/forum_thread.php?id=13588, this seems a more normal place to put the 'static' declaration.
cc_config.h: empirical, Can't set defaults in init(), so put them here instead.
Tested on
Windows (VS2013)
Linux Mint, based on Ubuntu (configure/make)