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

lock file for SingleInstanceService may be creaeted even if old one s… #646

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

vnashkev
Copy link

@vnashkev vnashkev commented May 25, 2020

…till exists.

Fix for #645

assert "123".equals(FileUtils.loadFileAsUtf8String(sil.lockFile).trim());


sil.createWithPort(456);
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Contributor

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 + "]");
Copy link
Contributor

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

@sclassen sclassen merged commit ee95fcc into AdoptOpenJDK:master Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants