Skip to content
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

Add Support for locking the registry #1828

Merged
merged 33 commits into from
Aug 29, 2016
Merged

Conversation

politas
Copy link
Member

@politas politas commented Jul 13, 2016

Closes #706
Working from previous PRs #1357, #1265

@Postremus
Copy link
Contributor

-launch gui
-try to start cli without parameters
The cli shows the CKAN is already running for this instance! error, but then opens a messagebox with the same text again.

@politas
Copy link
Member Author

politas commented Jul 14, 2016

What happens when you run CLI with no params without having the GUI open?
EDIT: Answer - It opens the GUI.
So this is expected behaviour. It's the same as running ckan -gui twice.

@politas politas added GUI Issues affecting the interactive GUI Cmdline Issues affecting the command line labels Jul 14, 2016
@Postremus
Copy link
Contributor

yes, but showing the error to the user twice (once in cli, once in gui) is not really needed.

@politas
Copy link
Member Author

politas commented Jul 18, 2016

There is a weird case where we are failing to create a lock file issue. When you start a second GUI instance selecting a different KSP install and then switch to the same install as the first instance. The second instance is killed, and all is well unless you then open a different KSP install with the first instance. Under that situation, it doesn't open a new lock file, and if you keep switching KSP installs it keeps not creating lock files. I can't find any other cases where lock files are not handled correctly, and this is going to be a pretty rare situation. But if anyone would like to try as many situations as they can imagine, any further issues might help to pin down the flaw.

@politas
Copy link
Member Author

politas commented Jul 19, 2016

Further investigation shows the second KSP instance is not the culprit. Returning to a KSP Install in which you have already had a lock file created and removed will not create a new lock file.

@politas
Copy link
Member Author

politas commented Jul 19, 2016

Ok, the only remaining issue I can find is the duplicated error messaging, and I'm happy to live with that.

@politas
Copy link
Member Author

politas commented Jul 19, 2016

needs more testing

@politas
Copy link
Member Author

politas commented Jul 30, 2016

Rebased after #1841

//Don't try to Dispose a null CurrentInstance.
if (CurrentInstance != null)
{
// Dispose of the old registry manager, to release the registry.
Copy link
Contributor

@ayan4m1 ayan4m1 Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible null dereference on RegistryManager.

@ayan4m1
Copy link
Contributor

ayan4m1 commented Aug 1, 2016

Per https://msdn.microsoft.com/en-us/library/ms229043.aspx and https://msdn.microsoft.com/en-us/library/ms229045(v=vs.110).aspx

DO use camelCasing for parameter names.
DO NOT use underscores, hyphens, or any other nonalphanumeric characters.

Some of the variables and parameters are in snake_case when you want them in camelCase.

I also added a few other style notes - not trying to be critical of your work at all in case it came off that way.

// Release the registry lock file if possible.
if (manager.CurrentInstance != null)
{
manager.CurrentInstance.RegistryManager.Dispose();
Copy link
Contributor

@ayan4m1 ayan4m1 Aug 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If manager.CurrentInstance.RegistryManager is null, this will throw a NullReferenceException. Take a look here for an elegant solution to these kinds of issues.

@politas
Copy link
Member Author

politas commented Aug 16, 2016

Oh of course. Mono 3.2.8 doesn't support Null Conditional Operators. Rolled that back to the ugly method, now improved to catch all possible nulls


///public void Dispose()
///{
/// this.RegistryManager.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this remains commented out, an additional comment explaining why it was commented out or what it did would be helpful.

pjf and others added 19 commits August 17, 2016 14:03
Disposing of the writer also disposes of the stream, but the
other way around (which we had) causes great sadness, or at least
an unhandled exception.
This should make windows users happy, as otherwise the files
can't be deleted at all!
This means our tests (and possibly other code) can get it to release
locks properly.
Need to drop the KSP registry information from the singleton[] array on RegistryManager.Dispose() or we will not create a new lock file if we return to a previously locked KSP Install
@politas
Copy link
Member Author

politas commented Aug 17, 2016

Ah yes, that little bug! Whacked again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cmdline Issues affecting the command line GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants