Skip to content

Commit

Permalink
Reset BUNDLED_KNOWN_HOSTS_FILE in case we serialized a value due to p…
Browse files Browse the repository at this point in the history
…recompilation (#31)
  • Loading branch information
vchuravy authored Sep 7, 2023
1 parent 976e51a commit aab83e5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ssh_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,26 @@ end
## helper functions

const BUNDLED_KNOWN_HOSTS_LOCK = ReentrantLock()
const BUNDLED_KNOWN_HOSTS_FILE = Ref{String}()
const BUNDLED_KNOWN_HOSTS_FILE = Ref{Union{Nothing, String}}(nothing)

function bundled_known_hosts()
lock(BUNDLED_KNOWN_HOSTS_LOCK) do
if !isassigned(BUNDLED_KNOWN_HOSTS_FILE)
BUNDLED_KNOWN_HOSTS_FILE[], io = mktemp()
file = BUNDLED_KNOWN_HOSTS_FILE[]
if file === nothing
file, io = mktemp()
BUNDLED_KNOWN_HOSTS_FILE[] = file
write(io, BUNDLED_KNOWN_HOSTS)
close(io)
end
return file::String
end
end

function __init__()
# Reset in case we serialized a value here.
lock(BUNDLED_KNOWN_HOSTS_LOCK) do
BUNDLED_KNOWN_HOSTS_FILE[] = nothing
end
return BUNDLED_KNOWN_HOSTS_FILE[]
end

const BUNDLED_KNOWN_HOSTS = """
Expand Down

0 comments on commit aab83e5

Please sign in to comment.