Add serialization of writes to known_hosts file.#16057
Merged
Merged
Conversation
96fb5e3 to
91c9e36
Compare
greedy52
reviewed
Sep 2, 2022
tigrato
approved these changes
Sep 2, 2022
greedy52
approved these changes
Sep 2, 2022
AntonAM
commented
Sep 2, 2022
greedy52
approved these changes
Sep 2, 2022
timothyb89
approved these changes
Sep 2, 2022
91c9e36 to
6361812
Compare
6361812 to
284e7b8
Compare
Contributor
This was referenced Sep 7, 2022
capnspacehook
pushed a commit
that referenced
this pull request
Sep 12, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We had a situation when multiple instances of
tshtried to write toknown_hostsfile and eventually corrupting it.To fix it we're trying to serlialize writes to the file, by first locking on it. Locking was chosen over lock files because it seems like a cleaner approach and we don't need to handle situation with leftover lock files in case something unexpected happens. With locks if process dies file is freed automatically.
I also added locking to the reads to account for potential situation when one instance of
tshpartly written content to the file and another intance tried to read and parse it. Not sure, how probable this potential situation is, but since the cost of locking is so low in our use case, I think it makes sense to add it anyway.Fixes #15298