This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch reproducible-widget-previews
in repository efl.

View the commit online.

commit e199f6bf4c97b62814a7710337356742406b3d25
Author: Alastair Poole <[email protected]>
AuthorDate: Sat May 2 16:26:48 2026 +0100

    ecore_con: fix HTTP dialer with curl 8.20 multi callbacks
    
    curl 8.20 may invoke multi socket callbacks during
    curl_multi_add_handle() for easy handles that are not the dialer's own
    easy handle. efl_net_dialer_http assumed every socket callback could be
    mapped through CURLINFO_PRIVATE and returned an error when that was not
    true, which made curl report the transfer as aborted by callback.
    
    Register the dialer before adding the easy handle, allow socket
    management for non-dialer/internal easy handles, and only attach the fd
    handler to the dialer state when the easy handle matches.
    
    Also handle the multi timer callback's negative timeout as a request to
    delete/disable the timer, and refresh the local CURLMcode copy/error
    mapping for newer libcurl multi errors.
---
 src/lib/ecore_con/ecore_con_url_curl.c  |  5 +++
 src/lib/ecore_con/ecore_con_url_curl.h  |  6 ++++
 src/lib/ecore_con/efl_net_dialer_http.c | 55 ++++++++++++++++++++++++---------
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/src/lib/ecore_con/ecore_con_url_curl.c b/src/lib/ecore_con/ecore_con_url_curl.c
index e107767e7e..bea0ff0b17 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.c
+++ b/src/lib/ecore_con/ecore_con_url_curl.c
@@ -161,6 +161,11 @@ _curlmcode_to_eina_error(const CURLMcode code)
     case CURLM_BAD_SOCKET: return ENOTSOCK;
     case CURLM_UNKNOWN_OPTION: return EINVAL;
     case CURLM_ADDED_ALREADY: return EALREADY;
+    case CURLM_RECURSIVE_API_CALL: return EBUSY;
+    case CURLM_WAKEUP_FAILURE: return EIO;
+    case CURLM_BAD_FUNCTION_ARGUMENT: return EINVAL;
+    case CURLM_ABORTED_BY_CALLBACK: return ECONNABORTED;
+    case CURLM_UNRECOVERABLE_POLL: return EIO;
 
     default:
        ERR("unexpected error CURLMcode=%d '%s', not mapped",
diff --git a/src/lib/ecore_con/ecore_con_url_curl.h b/src/lib/ecore_con/ecore_con_url_curl.h
index ed68e5c4f4..6791cd81df 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.h
+++ b/src/lib/ecore_con/ecore_con_url_curl.h
@@ -30,6 +30,12 @@ typedef enum
   CURLM_UNKNOWN_OPTION,  /* curl_multi_setopt() with unsupported option */
   CURLM_ADDED_ALREADY,   /* an easy handle already added to a multi handle was
                             attempted to get added - again */
+  CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
+                               callback */
+  CURLM_WAKEUP_FAILURE,  /* wakeup is unavailable or failed */
+  CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
+  CURLM_ABORTED_BY_CALLBACK,
+  CURLM_UNRECOVERABLE_POLL,
   CURLM_LAST
 } CURLMcode;
 
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c b/src/lib/ecore_con/efl_net_dialer_http.c
index e291914820..ba79307c9b 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -358,6 +358,16 @@ _efl_net_dialer_http_curlm_timer_schedule(CURLM *multi EINA_UNUSED, long timeout
    Efl_Net_Dialer_Http_Curlm *cm = data;
    double seconds = timeout_ms / 1000.0;
 
+   if (timeout_ms < 0)
+     {
+        if (cm->timer)
+          {
+             efl_del(cm->timer);
+             cm->timer = NULL;
+          }
+        return 0;
+     }
+
    if (cm->timer)
      {
         efl_loop_timer_interval_set(cm->timer, seconds);
@@ -376,6 +386,22 @@ _efl_net_dialer_http_curlm_timer_schedule(CURLM *multi EINA_UNUSED, long timeout
    return 0;
 }
 
+static Eo *
+_efl_net_dialer_http_curlm_easy_find(Efl_Net_Dialer_Http_Curlm *cm, CURL *easy)
+{
+   const Eina_List *l;
+   Eo *dialer;
+
+   EINA_LIST_FOREACH(cm->users, l, dialer)
+     {
+        Efl_Net_Dialer_Http_Data *pd = efl_data_scope_get(dialer, MY_CLASS);
+        if ((pd) && (pd->easy == easy))
+          return dialer;
+     }
+
+   return NULL;
+}
+
 static void
 _efl_net_dialer_http_curlm_event_fd_read(void *data, const Efl_Event *event)
 {
@@ -408,22 +434,19 @@ static int
 _efl_net_dialer_http_curlm_socket_manage(CURL *e, curl_socket_t fd, int what, void *cm_data, void *fdhandler_data)
 {
    Efl_Net_Dialer_Http_Curlm *cm = cm_data;
-   Efl_Net_Dialer_Http_Data *pd;
+   Efl_Net_Dialer_Http_Data *pd = NULL;
    Eo *dialer, *fdhandler = fdhandler_data;
-   char *priv;
-   CURLcode re;
 
-   re = curl_easy_getinfo(e, CURLINFO_PRIVATE, &priv);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(re != CURLE_OK, -1);
-   if (!priv) return -1;
-   dialer = (Eo *)priv;
-   pd = efl_data_scope_get(dialer, MY_CLASS);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(pd, -1);
+   dialer = _efl_net_dialer_http_curlm_easy_find(cm, e);
+   if (dialer)
+     pd = efl_data_scope_get(dialer, MY_CLASS);
 
    if (what == CURL_POLL_REMOVE)
      {
-        pd->fdhandler = NULL;
-        efl_del(fdhandler);
+        if ((pd) && (pd->fdhandler == fdhandler))
+          pd->fdhandler = NULL;
+        curl_multi_assign(cm->multi, fd, NULL);
+        if (fdhandler) efl_del(fdhandler);
      }
    else
      {
@@ -434,9 +457,10 @@ _efl_net_dialer_http_curlm_socket_manage(CURL *e, curl_socket_t fd, int what, vo
           flags = (intptr_t)efl_key_data_get(fdhandler, "curl_flags");
         else
           {
-             pd->fdhandler = fdhandler = efl_add(EFL_LOOP_FD_CLASS, cm->loop,
-                                                 efl_loop_fd_set(efl_added, fd));
+             fdhandler = efl_add_ref(EFL_LOOP_FD_CLASS, cm->loop,
+                                     efl_loop_fd_set(efl_added, fd));
              EINA_SAFETY_ON_NULL_RETURN_VAL(fdhandler, -1);
+             if (pd) pd->fdhandler = fdhandler;
              curl_multi_assign(cm->multi, fd, fdhandler);
              flags = 0;
           }
@@ -494,16 +518,17 @@ _efl_net_dialer_http_curlm_add(Efl_Net_Dialer_Http_Curlm *cm, Eo *o, CURL *handl
         curl_multi_setopt(cm->multi, CURLMOPT_TIMERDATA, cm);
      }
 
+   cm->users = eina_list_append(cm->users, o);
+
    r = curl_multi_add_handle(cm->multi, handle);
    if (r != CURLM_OK)
      {
         ERR("could not register curl multi handle %p: %s",
             handle, curl_multi_strerror(r));
+        cm->users = eina_list_remove(cm->users, o);
         return EINA_FALSE;
      }
 
-   cm->users = eina_list_append(cm->users, o);
-
    return EINA_TRUE;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to