Skip to content

Commit bbbcc4f

Browse files
gbaraldivchuravy
andauthored
Add lock around uv_unref during init (#51236)
This is not a legal operation outside the lock because it's not atomic Co-authored-by: Valentin Churavy <[email protected]>
1 parent 8d4d641 commit bbbcc4f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

base/libuv.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,17 @@ uv_error(prefix::AbstractString, c::Integer) = c < 0 ? throw(_UVError(prefix, c)
103103

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

106-
uv_unref(h::Ptr{Cvoid}) = ccall(:uv_unref, Cvoid, (Ptr{Cvoid},), h)
107-
uv_ref(h::Ptr{Cvoid}) = ccall(:uv_ref, Cvoid, (Ptr{Cvoid},), h)
106+
function uv_unref(h::Ptr{Cvoid})
107+
iolock_begin()
108+
ccall(:uv_unref, Cvoid, (Ptr{Cvoid},), h)
109+
iolock_end()
110+
end
111+
112+
function uv_ref(h::Ptr{Cvoid})
113+
iolock_begin()
114+
ccall(:uv_ref, Cvoid, (Ptr{Cvoid},), h)
115+
iolock_end()
116+
end
108117

109118
function process_events()
110119
return ccall(:jl_process_events, Int32, ())

0 commit comments

Comments
 (0)