Skip to content

Commit

Permalink
Avoid potential race between read and upload_data
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed Aug 30, 2023
1 parent 246504e commit 83212de
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Curl/Easy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,11 @@ end
# feed data to read_callback
function upload_data(easy::Easy, input::IO)
while true
data = eof(input) ? nothing : readavailable(input)
easy.input === nothing && break
easy.input = data
if easy.input === nothing || isempty(easy.input)
data = eof(input) ? nothing : readavailable(input)
easy.input === nothing && break
easy.input = data
end
curl_easy_pause(easy.handle, Curl.CURLPAUSE_CONT)
wait(easy.ready)
easy.input === nothing && break
Expand Down

0 comments on commit 83212de

Please sign in to comment.