Skip to content

curl hangs at 100% cpu usage on http/1.1 concurrent request with pipewait=1 #3813

Closed
@TvdW

Description

@TvdW

Initially found this as a bug on 7.64.1, where curl with CURLOPT_PIPEWAIT and CURLMOPT_MULTIPLEX on a HTTP/1.1 server would fail to execute requests concurrently until the second batch of requests were scheduled. However, the behavior seems to have gotten worse on the latest master, and now results in a curl hang at 100% CPU usage.

Code:

#include "curl/curl.h"

int main(int argc, char** argv)
{
    CURLM *multi = curl_multi_init();
    curl_multi_setopt(multi, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
    curl_multi_setopt(multi, CURLMOPT_MAX_HOST_CONNECTIONS, 4);

    int i;
    for (i = 0; i < 5; i++) {
        CURL *easy = curl_easy_init();
        curl_easy_setopt(easy, CURLOPT_URL, "https://httpbin.org/delay/2");
        curl_easy_setopt(easy, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(easy, CURLOPT_PIPEWAIT, 1);
        curl_easy_setopt(easy, CURLOPT_NOPROXY, "");
        curl_easy_setopt(easy, CURLOPT_PROXY, "http://my-http-proxy:3128");

        curl_multi_add_handle(multi, easy);
    }

    int running= 1;
    while (running) {
        int numfds;
        curl_multi_perform(multi, &running);
        curl_multi_wait(multi, NULL, 0, 1000, &numfds);
    }

    curl_multi_cleanup(multi);

    return 0;
}

On 7.64.1, this will take ~10 seconds to run. On master, this hangs.

* Connection #0 to host my-http-proxy left intact
* Found bundle for host httpbin.org: 0x1b99f00 [serially]
* Server doesn't support multiplex yet, wait
* No connections available.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions