cURL / Mailing Lists / curl-library / Single Mail


adding easy handles when using curl_multi_socket*

From: <>
Date: Tue, 29 Apr 2008 02:17:35 +0200


I found the "load.c" example for curl & libevent on the mailinglist and
played with it.

First some things aside, this api rocks, definitely a really good thing.
And you should consider taking a fixed load.c to the example code section.

I fixed load.c myself, and it is great.

Now my problem,
running the example code "load.c" with a ccy of 1, the execution stalls
after the first download is finished and the socket got removed from
When adding the new request, there is no call to
curl_multi_socket_action_all, so libevent is unaware of the new socket,
and waits for the timeout.
After the timeout the event_dispatch halts, as there is no event to poll

Calling curl_multi_socket_all after adding the new request, I get
unreproduceable 'strange' behaviour.

I get a timeout for a socket, but
curl_multi_socket(,CURL_SOCKET_TIMEOUT,) returns error and the message
says the socket is not in use ..., and the process stalls.

I lost the exact message, scrolled out of my buffer when adding debug,
and I can't reproduce it now ...

My best guess is, that curl_multi_socket_all can finish a easy handle,
therefore my eventhandler callback is not called, and I'm unaware of
the finished download.
The event api is unaware of the finished download too, still polling the
socket, returning an event on the closed(?) socket.
When curl gets this event, the socket is not bound to an easy handle any

So I had a look on the documentation on "TYPICAL USAGE" at

Adding new easy handles to a running multi handle in _socket mode is not
mentioned, why?

Markus Kötter
Received on 2008-04-29