efl_net_dialer_http: allow delete/close from CURL callbacks.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Wed, 31 Aug 2016 13:19:04 +0000 (10:19 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 2 Sep 2016 03:08:50 +0000 (00:08 -0300)
commitd12ff74f5fd93497a5c9c3ddd3bd52f7bcbe3e5d
treeb53ec7518669cbae4cb659d76cf632a46342a071
parent4ee09c5bdb905568134a0856962ea99f3dc53ffb
efl_net_dialer_http: allow delete/close from CURL callbacks.

CURL doesn't play nice if handles are deleted or modified while it's
dispatching the callbacks, then we must not touch the CURL* easy
handle in those cases, just dissociate the handle from object and
schedule a job to do the deletion later.

Also, since from CURL callbacks we do not have the reference to the
object, if they are deleted from inside the callback, users of 'pd'
will crash. Thus keep an extra reference while the object and its
private data are in use.

The curl_multi_info_read() is used to notify of errors and
end-of-stream, if we do callback directly from there, the user may
efl_del(dialer), which will result in the "pd->easy" being destroyed
with curl_easy_cleanup() then "cm" and "cm->multi" being destroyed.

Thus postpone that action and keep a list of finished objects, calling
their event handlers which can delete the object (or siblings), thus
ref before dispatching and unref afterwards, taking care to monitor
EFL_EVENT_DEL so we do not use stale objects.
src/lib/ecore_con/efl_net_dialer_http.c