Skip to content

Commit

Permalink
Add lock around uv_unref during init (#51236)
Browse files Browse the repository at this point in the history
This is not a legal operation outside the lock because it's not atomic

Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
(cherry picked from commit bbbcc4f)
  • Loading branch information
gbaraldi authored and nalimilan committed Nov 5, 2023
1 parent a0fc853 commit 8fb6542
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions base/libuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,17 @@ uv_error(prefix::AbstractString, c::Integer) = c < 0 ? throw(_UVError(prefix, c)

eventloop() = ccall(:jl_global_event_loop, Ptr{Cvoid}, ())

uv_unref(h::Ptr{Cvoid}) = ccall(:uv_unref, Cvoid, (Ptr{Cvoid},), h)
uv_ref(h::Ptr{Cvoid}) = ccall(:uv_ref, Cvoid, (Ptr{Cvoid},), h)
function uv_unref(h::Ptr{Cvoid})
iolock_begin()
ccall(:uv_unref, Cvoid, (Ptr{Cvoid},), h)
iolock_end()
end

function uv_ref(h::Ptr{Cvoid})
iolock_begin()
ccall(:uv_ref, Cvoid, (Ptr{Cvoid},), h)
iolock_end()
end

function process_events()
return ccall(:jl_process_events, Int32, ())
Expand Down

0 comments on commit 8fb6542

Please sign in to comment.