From 83212def27a030b9c145f8cc7494602a22040954 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Wed, 30 Aug 2023 15:03:30 -0300 Subject: [PATCH] Avoid potential race between read and upload_data --- src/Curl/Easy.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Curl/Easy.jl b/src/Curl/Easy.jl index cf63f50..4855010 100644 --- a/src/Curl/Easy.jl +++ b/src/Curl/Easy.jl @@ -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