]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: on socket callback error, remove socket hash entry nonetheless
authorDaniel Stenberg <daniel@haxx.se>
Thu, 15 Aug 2024 09:06:38 +0000 (11:06 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 15 Aug 2024 16:49:16 +0000 (18:49 +0200)
Previously an error from the callback accidentally made libcurl keep the
hash entry which would lead to the entry remaining and then potentially
getting removed *again* which would lead to internal confusions.

This is an old issue (introduced in 2b3dd01b779e4eff6), caught by the new
asserts from c0233a35da81.

Closes #14557

lib/multi.c

index 2e62e56b6242095f7f79a6535e5fe846b4e30889..b07ebe5d07def14cf83ef12ca4cf078eef44a6a8 100644 (file)
@@ -3013,17 +3013,20 @@ CURLMcode Curl_multi_pollset_ev(struct Curl_multi *multi,
       if(oldactions & CURL_POLL_IN)
         entry->readers--;
       if(!entry->users) {
+        bool dead = FALSE;
         if(multi->socket_cb) {
           set_in_callback(multi, TRUE);
           rc = multi->socket_cb(data, s, CURL_POLL_REMOVE,
                                 multi->socket_userp, entry->socketp);
           set_in_callback(multi, FALSE);
-          if(rc == -1) {
-            multi->dead = TRUE;
-            return CURLM_ABORTED_BY_CALLBACK;
-          }
+          if(rc == -1)
+            dead = TRUE;
         }
         sh_delentry(entry, &multi->sockhash, s);
+        if(dead) {
+          multi->dead = TRUE;
+          return CURLM_ABORTED_BY_CALLBACK;
+        }
       }
       else {
         /* still users, but remove this handle as a user of this socket */