Fix potential deadlock during process fork #817
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix a potential deadlock in post_fork().
Description of the Change
close_socket acquires _socket_lock, and calling it with the lock held deadlocks.
On top of this the warning did not prove very useful, as it would also trigger when the application is sending metrics from another thread when the process forks, in which case the warning is a bit misleading.
Without the warning there is no reason to check for socket being open, so just silently call close_socket() after the fork to avoid sharing the file descriptor between processes if another thread re-opened it between pre_fork() and fork itself.
Alternate Designs
Possible Drawbacks
Verification Process
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/
label attached. If applicable it should have thebackward-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.