Skip to content

Commit

Permalink
Do not mess with the GC. There shouldn't be a race condition here.
Browse files Browse the repository at this point in the history
If the function is called manually, the variable is referenced from the stack.
If the function is called called as finalizer, the GC will make sure it is not called twice.
  • Loading branch information
yuyichao committed Aug 9, 2015
1 parent 2d53fff commit dd3acb8
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/GZip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,10 @@ gzdopen(s::IOStream, args...) = gzdopen(fd(s), args...)
fd(s::GZipStream) = error("fd is not supported for GZipStreams")

function close(s::GZipStream)

# The garbage collector needs to be temporarily disabled because of a possible
# race condition if it runs between testing and setting s._closed

gc_enable(false)
if s._closed
gc_enable(true)
return Z_STREAM_ERROR
end
s._closed = true
gc_enable(true)

s.name *= " (closed)"

Expand Down

0 comments on commit dd3acb8

Please sign in to comment.