On Wed, 10 Dec 2014, Lindley French wrote:

This is pure libcurl talk so I took it off the curl-users list. However your original mails have only showed up in the curl-users archive (http://curl.haxx.se/mail/archive-2014-12/0009.html) and not in the curl-library archive which makes me suspect you're not subscribed to curl-library (yet). Please do before you respond to this so that your mail reaches everyone!

One thing isn't clear to me, though. If I have a thread dedicated to
blocking on select() and then calling curl_multi_perform(), then it seems
like I need to get my outgoing requests onto that thread somehow.

A single multi handle can handle any amount of incoming and outgoing requests.

(In an async world, it seems like it shouldn't be necessary to do writing and reading on the same thread, but the prohibition against sharing curl handles between threads requires it.)

No it doesn't require it. You can have two threads, each with its own multi handle and you can have one do downloads and one do uploads... But yeah, there may be reasons why that isn't right for you.

Question: is there a best practice for doing this in curl, or do I just have to hack something up with a deque and a mutex?

Why not simply add your outgoing work in a queue that you can read from as often as possible in the select()-using thread? You can even trigger the select() to return with a pipe or similar.

[from your follow-up mail]

Question: is there a way to connect two curl handles to each other, so that
writing to one causes the other to become readable? This would let me wake
up a select() call at an arbitrary time.

Use a pipe.

I could do this other ways, but I'm looking for a solution that will work on both Linux and Windows.

On Windows, select() can only wait on sockets so you'd have to create a socket instead of a pipe. Less performant and more work, but should still be doable.

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to