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

PICARD-2722: Avoid pipe thread respawning on exit on Windows #2295

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

phw
Copy link
Member

@phw phw commented Aug 30, 2023

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences:

Problem

Closing Picard on Windows can lead to an exception when closing the pipe while also have the pipe server thread still running. The reason is a race condition when sending the close message to the pipe. As the pipe gets recreated after it was read from it could happen that the pipe was running again before the application closed.

Solution

Only re-create the pipe if it was not marked as stopped. Also avoid exceptions when attempting to close the handle.

The second commit of this PR also solves a smaller problem, where on starting Picard under Windows there would always be a log output

E: 18:54:33,314 util/pipe.send_to_pipe:274: pipe sender exception: (2, 'CreateFile', 'The system cannot find the file specified.')

This was caused by the attempt to write to the pipe, which is done for probing whether a process already has the pipe or not.

Only re-create pipe on Windows if it was not stopped. Otherwise
re-creating the pipe can cause the pipe server thread to keep running.
When starting the initial instance the pipe not being available to
write to is an expected condition. Handle this gracefully.
@phw phw requested a review from zas August 30, 2023 16:57
@phw
Copy link
Member Author

phw commented Aug 30, 2023

The issue is hard to reproduce on my system. I could not intentionally trigger it, but it happened from time to time. With the patch it hasn't happened so far.

Copy link
Collaborator

@zas zas left a comment

Choose a reason for hiding this comment

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

I can't test it, but it looks good.

@phw phw merged commit 542325b into metabrainz:master Aug 31, 2023
63 checks passed
@phw phw deleted the PICARD-2722 branch September 8, 2023 06:02
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.

2 participants