]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: start the loop over when handles are removed
authorDaniel Stenberg <daniel@haxx.se>
Tue, 4 Mar 2025 13:00:03 +0000 (14:00 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Mar 2025 15:10:49 +0000 (16:10 +0100)
Since more than one handle can be removed in a single call to
multi_runsingle(), we cannot easily continue on the next node when a
node has been removed since that node migth ALSO have been removed.

Reported-by: Philippe Antoine
Closes #16588

lib/multi.c

index ae221d4f4672e92e5df96389f99453284497d635..f34758070212bf32bdcee607a0c3d7e77e12d60b 100644 (file)
@@ -2601,6 +2601,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles)
   for(e = Curl_llist_head(&multi->process); e; e = n) {
     struct Curl_easy *data = Curl_node_elem(e);
     CURLMcode result;
+    unsigned int num_alive = multi->num_alive;
     /* Do the loop and only alter the signal ignore state if the next handle
        has a different NO_SIGNAL state than the previous */
     if(first) {
@@ -2619,6 +2620,12 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles)
       if(result)
         returncode = result;
     }
+    if(num_alive != multi->num_alive)
+      /* Since more than one handle can be removed in a single call to
+         multi_runsingle(), we cannot easily continue on the next node when a
+         node has been removed since that node might ALSO have been
+         removed. */
+      n = Curl_llist_head(&multi->process);
   }
 
   sigpipe_apply(multi->admin, &pipe_st);