-
Notifications
You must be signed in to change notification settings - Fork 238
Persistent server lists using --directoryfile #1867
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
Persistent server lists using --directoryfile #1867
Conversation
2228e33 to
69c4d1c
Compare
69c4d1c to
81c4a5d
Compare
|
Todo:
|
Agreed - I've run this the way I expect it to work. I've not tried to break it at all.
Also agreed. I know @softins has looked at the directory server code; it also looks like @passing and @hoffie have touched it: |
|
With 2bd1654 I have touched all the code 😄 |
Ah yes, true... |
|
No error message is given if we run a non directory server. (Fixed for non GUI servers)
Only after gracefully stopping a directory the file gets written which means that we don't handle a crash. Is this intended? All in all I think it's on a good way to get merged. |
|
Thanks for the negative tests!
Well, a warning message - it'll carry on starting up at that point.
Mm, yes... I need to say "either it doesn't exist or it's a file". I could do that in Overall, I'm tempted to going back to requiring an existing, readable, writeable file to be passed: no sudden surprises that way. |
|
Hm. Made worse by the server ini file. I can use a server ini file to set my server list to "custom" "localhost" and run as a directory server. On start up, as I don't supply Like I've said elsewhere, we need to refactor start up further -- parse the command line options, load the ini file (either default or specified) and then override ini file from command line. Currently, it's the other way around (ini file overrides command line), which feels totally wrong. Once all of that's been done, then validate the settings work together -- you (should) know what got to the ini file was valid, so it's only going to be command line options causing the problem. As it stands, I can't know whether I'm running as a directory server when parsing the command line options. Or even if I'm registering. |
81c4a5d to
cf3b6f0
Compare
|
Well, after several attempts, I've come up with something that does the best it can. If we're a headless server, there is no inifile (regardless of passing the argument), so the command line specifies everything there is to know. Otherwise, certain checks cannot be made as the inifile might change things. I might have missed some bits, though. Ugh, I also left some changes in I'd meant to revert. |
5c0a262 to
1ce9665
Compare
|
And, of course, whilst I was tidying up, I did some more changes... Now running on all my directory servers and my jam server. |
| if ( !strServerListFilter.isEmpty() ) | ||
| { | ||
| qWarning() << "Server list filter will only take effect when running as a directory server."; | ||
| strServerListFileName = ""; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| if ( !strServerListFileName.isEmpty() ) | ||
| { | ||
| QFileInfo serverListFileInfo ( strServerListFileName ); | ||
| if ( !serverListFileInfo.exists() ) | ||
| { | ||
| QFile strServerListFile ( strServerListFileName ); | ||
| if ( !strServerListFile.open ( QFile::OpenModeFlag::ReadWrite ) ) | ||
| { | ||
| qWarning() << qUtf8Printable ( | ||
| QString ( "Cannot create %1 for reading and writing. Please check permissions." ).arg ( strServerListFileName ) ); | ||
| strServerListFileName = ""; | ||
| } | ||
| } | ||
| else if ( !serverListFileInfo.isFile() ) | ||
| { | ||
| qWarning() << qUtf8Printable ( | ||
| QString ( "Server list file %1 must be a plain file. Please check the name." ).arg ( strServerListFileName ) ); | ||
| strServerListFileName = ""; | ||
| } | ||
| else if ( !serverListFileInfo.isReadable() || !serverListFileInfo.isWritable() ) | ||
| { | ||
| qWarning() << qUtf8Printable ( | ||
| QString ( "Server list file %1 must be readable and writeable. Please check the permissions." ) | ||
| .arg ( strServerListFileName ) ); | ||
| strServerListFileName = ""; | ||
| } | ||
| } | ||
|
|
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.
Hmm. It's a lot of new code in main.cpp 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.
Yep - you suggested that --directoryfile should only be allowed when running as a directory server. That meant lots of new code. As I was doing it for the one option, it felt necessary to be consistent, so I did it for as many I as I could. And that meant refactoring to avoid repetition.
It's a lot cleaner now than it was, with multiple "if this then not that" sections all mixed in with each other.
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. I know. Probably it's a good move then anyway. So the next steps would be another few tests and another person who reviews this.
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 CClientSettings and CServerSettings need, respectively, to be passed an instance of CClient and CServer. Which means you have to create the Client or Server before loading the inifile. The class in question configures itself according to its defaults or command line option overrides. Then, if there's an inifile (i.e. not headless server), a whole load of other options get applied, changing how the class is configured.
This is why you cannot know whether a server is a directory server if it's not headless when
- validating the command line options
- when creating the server instance
It's not until during inifile loading that you know. That's after the directoryfile parameter has been set in the server. Too late now!
All of this is confusing -- it leaves me totally confused every time I have to think about it, anyway.
So what I want to do is make it so:
- the command line arguments are read
- the decision on Client vs Server is made
- the appropriate CSettings object gets created, but just reading the entries in from the inifile
- the command line options are sanity checked against the CSettings object and, if sane, applied
- the CClient or CServer object gets created, passing in the CSettings object
- the application runs, making changes to the CSettings object in place of the current settings values
- on shutdown, the CSettings object is saved to the inifile - excluding any entry from the command line options, which is left "as is" in the file
(Volker didn't like it...)
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.
Thanks for the explanation.
This seems to explain why my tests with the GUI didn't do what I thought they would do: I set up a GUI directory via CLI which resulted in a message saying it is a directory, but I couldn't register with it or have the register my server box checked.
There must be a reason why Volker defended the current implementation?
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 it was very much "that's the way it's always worked, why change it?". Which is valid if you're trying to reduce the amount of change being made to something you have [edit]limited[/edit] time to manage, which he was.
|
Compiling on Linux gives a warning: Probably you'll need to move methods around. |
|
Just re-ran the auto build again since Android seemed to be broken. I think this PR would be ready then, however, I'd like to wait for others to test it too. |
1ce9665 to
a0026a4
Compare
Good spot - CodeQL should have objected more vigorously to the new warning, too. |
a0026a4 to
282fc6e
Compare
|
Missing:
|
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.
Works as expected; however the cli handling is - as you mentioned - not perfect. But that's not part of this PR.
282fc6e to
7db4dcf
Compare
|
OK, I've just split #1896 out from this - this still has that commit in, as I'm depending on it locally. |
7db4dcf to
a681ce5
Compare
softins
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.
This appears to include all the changes that are separately in #1896. I've approved the latter; maybe that needs to be merged first and this PR then rebased again?
|
No. I think if this PR is merged, the other one will close automatically? |
59c3e69 to
13cd055
Compare
…mmand line option
13cd055 to
7d9164a
Compare
|
@softins this PR is about something else (persistent server lists for directories)? |
Yes, but it had been branched off the commit for #1896 rather than directly off master. Now that #1896 has been merged, this PR only contains code relevant to the intended improvement. On first read through it looks good. I'll try it out later and approve after that. |
softins
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.
Just tested this out on my Pi and it appears to work fine. Approving. Thank you Peter!
Short description of changes
This change makes the server lists supplied by directory servers more reliable.
Context: Fixes an issue?
A number of users have complained server lists are not available reliably. When a directory server is restarted, it could take up to 15 minutes for all the servers registered with it to re-register. With this change in place, the directory should be fully populated on start up.
Does this change need documentation? What needs to be documented and how?
The help output has been added.
The Server Administrators' Guide will need updating to cover this option, when it's needed and how to use it.
It relies on the server administrator specifying a file in which to store the list across restarts.
Status of this pull request
Replacement for #1799 and pljones#9. Makes #1803 and #1804 redundant. All of those now closed.
This is running on all my directory servers (i.e. the genre-specific ones, plus my additional ones).
I'll also be using the Windows Client code (just to confirm no adverse side effects) from 19th June onwards.
What is missing until this pull request can be merged?
Review of the latest version of the code.
Checklist