]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
curl-glue: catch libcurl attempting to change timeout handler when we destroy a curl...
authorLennart Poettering <lennart@poettering.net>
Sat, 11 May 2024 11:45:44 +0000 (13:45 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 May 2024 20:29:15 +0000 (05:29 +0900)
If we destroy both an event loop and a curl contect object at the same
time, then we get into this weird situation where curl wants us to
reconfigure a timout event source right before destruction, which
sd-event will refuse however, since it is already being shutdown.

Hence, catch that and simply don't bother adjusting the timeout, since
we cannot get back from there anyway.

src/import/curl-util.c

index 10f2aa0468e1f36ed37f069e9ee34985569d032e..1628f833a970a0e7d50e7438ccf3b60f5aebf927 100644 (file)
@@ -134,6 +134,13 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
 
         assert(curl);
 
+        /* Don't configure timer anymore when the event loop is dead already. */
+        if (g->timer) {
+                sd_event *event_loop = sd_event_source_get_event(g->timer);
+                if (event_loop && sd_event_get_state(event_loop) == SD_EVENT_FINISHED)
+                        return 0;
+        }
+
         if (timeout_ms < 0) {
                 if (g->timer) {
                         if (sd_event_source_set_enabled(g->timer, SD_EVENT_OFF) < 0)