cURL / Mailing Lists / curl-library / Single Mail

curl-library

Pause/Resume POST using libcurl-multi and libevent

From: Vivek S <svivekchellam_at_gmail.com>
Date: Tue, 19 Jul 2016 23:42:04 +0530

Am using multi interface of libcurl and libevent2 in multi threaded
Linux application.

My application has two threads; first thread to listen for events on
curl fds and read/write data, and second thread to feed data for
POST/upload requests. Am using CURLOPT_READFUNCTION to read data from
buffer that is filled by another thread.

My problem is that sometimes the feed-thread fills the buffer slowly
(for valid reasons). To handle this I need to pause the curl-transfer
till the buffer has some data. Right now am using curl_easy_pause in
CURLOPT_READFUNCTION callback to pause the transfer when buffer is
empty and trying to resume the transfer whenever the buffer has some
data in CURLOPT_XFERINFOFUNCTION callback. But according the libcurl
document, CURLOPT_XFERINFOFUNCTION callback wont be called in case of
multi-curl interface when there is no transfer on the fd/handle. So
the resume never happens.

I would like to know how to resume the curl transfer(upload) when the
buffer has some data. Should I add timeout event that triggers
curl_multi_socket_action()? Doing that calls CURLMOPT_TIMERFUNCTION
callback with 598 secs of timeout which is too long.
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-07-19