Skip to content

Commit

Permalink
make read() respect lock=false
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Sep 26, 2021
1 parent 8987bc2 commit ef462ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ end
if ENDIAN_BOM == 0x04030201
function read(s::IOStream, T::Union{Type{Int16},Type{UInt16},Type{Int32},Type{UInt32},Type{Int64},Type{UInt64}})
n = sizeof(T)
lock(s.lock)
l = s._dolock
_lock = s.lock
l && lock(_lock)
if ccall(:jl_ios_buffer_n, Cint, (Ptr{Cvoid}, Csize_t), s.ios, n) != 0
unlock(s.lock)
l && unlock(_lock)
throw(EOFError())
end
x = ccall(:jl_ios_get_nbyte_int, UInt64, (Ptr{Cvoid}, Csize_t), s.ios, n) % T
unlock(s.lock)
l && unlock(_lock)
return x
end

Expand Down

0 comments on commit ef462ae

Please sign in to comment.