Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TvdW opened this issue Apr 29, 2019 · 0 comments
Closed
Assignees
Labels

Comments

@TvdW
Copy link

TvdW commented Apr 29, 2019

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.
@bagder bagder added the HTTP label Apr 29, 2019
@bagder bagder self-assigned this Apr 29, 2019
@bagder bagder closed this as completed in c32248f May 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

2 participants