cURL / Mailing Lists / curl-library / Single Mail


Adding CURL handles to running CURLM

From: <>
Date: Fri, 15 May 2015 08:19:16 +0000


My question - is it valid to call curl_multi_add_handle() for CULRM handle that is already running? Or should it only be called before curl_multi_perform() ?

I'm experiencing problem with HTTPS uploads using C++ CURL based client. File upload is done in 4MB chunks and server side always hangs at second chunk when total of 7-8 MBs were transferred. TCP logs show that window size spontaneously decreases to zero and it responds to client with zero window responses - meaning that buffer is full. Meanwhile server application code hangs on waiting for more data and never receives it. After this CURL sends zero window probes until timeouts.

Moreover - this problem only occurs when using Windows Server 2008 (IIS 7.5) and HTTPS. Using non secure HTTP or Windows Server 2012 (IIS 8.0 both HTTP and HTTPS) works fine.
Curl version does not seem to affect anything - I tested using libcurl/7.29.0 OpenSSL/1.0.1e and libcurl/7.37.0 OpenSSL/1.0.1j on iOS 8 and Windows 7 x64 builds.
Downloads and small uploads work fine.

This might be due to my misuse of CURLM, but I'm not sure. Basic idea of client side logic:

Application is able to submit HTTP requests to queue.
Queue is used in separate WEB thread that has running loop:
1) If no requests are running and queue is empty - wait for new requests
2) Pop new requests, create CURL easy handles
3) Call curl_multi_add_handle() - add new CURL handles to shared CURLM handle
4) Call curl_multi_perform()
5) Call curl_multi_info_read() - handle all CURLMSG_DONE messages, call curl_multi_remove_handle() and curl_easy_cleanup() for those.
6) Wait for new data or additions to queue (custom fdset) by calling curl_multi_timeout(), curl_multi_fdset() and select().
7) Go to 1)

Changing this to use different CURLM handles for each request fixes problem, but nullifies idea or background thread that manages transfers. I also tried removing step 6) and using busy-loop but that does not fix the issue.
Is there better approach for implementing background HTTP client service with CURL?


List admin:
Received on 2015-05-15