cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Crash while using curl_multi_socket_action

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

Lets say socket_call_back_libcurl is associated with
CURLMOPT_SOCKETFUNCTION
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)
       remove_socket_and_associated_data();

     if(user data == NULL)
     {

call_a_function_which_makes_association_between_sockfd_and_event_and_store_it_as_userdata_and_assing_it_to_curl_multi_assign(..........,
......,);
   }
  else
  {
    //other logic
    call_function_to_do_curl_multi_socket_action()
  }

  call_a_function_which_makes_association_between_sockfd_and_event_and_store_it_as_userdata_and_assing_it_to_curl_multi_assign(..........,
......,)
{
      //associate sockfd and event and store it in userdata
     curl_multi_assign(socket, userdata);
    call_function_to_do_curl_multi_socket_action()
}

call_function_to_do_curl_multi_socket_action()
{
  //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
{
  multihandle;
 lot of easy handles;
};

handle handleinfo;

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-28