curl-library
does curl_multi handle can be accessed from 2 threads?
Date: Fri, 1 Sep 2006 19:04:23 +0200
Hello,
I'm new to this library and I consider using it in my application.
What my application (service) should to is having *several* clients that are
always ready to recieve http requests, execute them and return the answer.
I was looking at some multi examples, and currently what I'm thinking to do
is a s follows:
I will have 2 threads:
1st thread is initializing the multi handle and running in endless loop
doing the following (more or less):
while (true)
{
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
}
I will have of course my own write function, and notify the 2nd thread (see
below) upon transfer completion.
2nd thread is my main thread. It will generally wait on a queue for
messages.
Those messages may be a new coming request or a notification of a completion
of a finished request (see above).
Upon a new request, I need to execute it. So I will initialize an easy
handle (or reuse an old one).
The question is:
can I use
curl_multi_add_handle(multi_handle, http_handle);
On this thread for adding new requests to process?
Is it thread safe?
If not, can you instruct me how to keep adding new requests in one thread
and still use a select on another thread?
Thank you,
Ori.
Received on 2006-09-01