cURL / Mailing Lists / curl-library / Single Mail


Re: Crash while using curl_multi_socket_action

From: sandeep a <>
Date: Wed, 28 Dec 2011 09:25:21 +0400

Lets say socket_call_back_libcurl is associated with
and libevent_callback_for_socket_action is the one which calls
curl_multi_socket_action. Then if my flow is

socket_call_back_libcurl(.sockfd, event.,.userdata.,...)
    if(even it to remove socket)

     if(user data == NULL)

    //other logic

      //associate sockfd and event and store it in userdata
     curl_multi_assign(socket, userdata);

  //register a function with libevent to do actual socket_action
  libevent_register(libevent_callback_for_socket_action, socket_fd, event);
//call me when event happens on that sockf_fd

What I mean by different threads is, 1 thread is created by libcurl
(libcurl context, as curl calls its call backs in its own thread context)
and 2nd thread created by libevent (libevent_callback_for_socket_action is
invoked in libevent thread context). That is what i meant by different
threads. I am not creating any more threads. Also I am passing multi handle
and easy handles as function arguments across curl call backs and libevent
call backs. Is my design still an issue? and hence the crash? or is the
crash due to a different issue? Do I need explicit synchronization
mechanisms (mutext lock) between curl call backs and libevent callbacks.
Assume handleinfo object as defined below. I am passing the object (which
internally contains multihandle and easy handles) as function parameters
between curlcall backs and libevent callbacks? I guess this should not be a
problem. Please correct me if I am still wrong.

class handle
 lot of easy handles;

handle handleinfo;

List admin:
Received on 2011-12-28