-
Notifications
You must be signed in to change notification settings - Fork 87
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
lock file for SingleInstanceService may be creaeted even if old one s… #646
lock file for SingleInstanceService may be creaeted even if old one s… #646
Conversation
assert "123".equals(FileUtils.loadFileAsUtf8String(sil.lockFile).trim()); | ||
|
||
|
||
sil.createWithPort(456); |
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.
Should this really be possible? I would assume that a lock must be removed before a new one can be created.
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.
Icedtea-web does not remove lock file neither before application start nor after application termination. At least i was not able to find this is source code.
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.
mmh, ok. I would assume that creating a lock will create a file and remove a lock will delete the file. Creating a without deleting a previous lock should throw an exception. But I will have a deeper look.
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 naming of this is bad.
The lock file is not used for locking but for broadcasting a port.
This port is then used as
- a lock because only one process can listen on a port
- a communication channel to inform the running application that a second instance should be started
@@ -240,6 +240,8 @@ public static void deleteWithErrMesg(File f) { | |||
private static void createRestrictedFile(File file, boolean isDir) throws IOException { | |||
|
|||
File tempFile = new File(file.getCanonicalPath() + ".temp"); | |||
FileUtils.deleteWithErrMesg(tempFile, "Could not delete [" + tempFile + "]"); |
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.
maybe it would be better to do this at the end of the method to prevent race conditions where two threads try to create the same file
…till exists.
Fix for #645