cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_socket_action and pipelining

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 18 Jun 2015 14:07:29 +0200 (CEST)

On Thu, 18 Jun 2015, Cristian Morales Vega wrote:

> I may have found a bug, but could somebody tell me how you are supposed to
> use the curl_multi_socket_action API when using pipelining?

The API is supposed to work the same way, pipelining or not.

> My problem is that the requests are pipelined, but not in the order in which
> they were curl_multi_add_handle()ed. Instead the requests are sent in an
> apparently random order.

libcurl never guarantees the order of the transfers you add to a multi handle,
so this is actually not that different. They're run in parallel.

> When using curl_multi_perform() instead, which I think is what all the curl
> tests use when testing pipelining, the requests are done correctly, in
> order.

First, the tests are unreliable if they make such assumptions. Then, I will
still claim that you get this behavior thanks to some circumstances in the
code rather than any attempted guarantees in the API.

This said, we don't make it "random" on purpose and I'm not aware of any
particular functionality what would prevent libcurl from doing them in order.

> I have tried delaying the curl_multi_add_handle() calls until the first one
> finishes, but it doesn't help.

Surely that will make the second transfer get performed after the first one?
Or what do you mean with it doesn't help?

> curl_multi_socket_action is the recommended multi interface, isn't it?

curl_multi_socket_action is the recommended way to do libcurl event-based. If
you're fine with a select()-oriented application there's nothing wrong with
curl_multi_perform().

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-06-18