1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

curl-glue: catch libcurl attempting to change timeout handler when we destroy a curl context on exit

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.
This commit is contained in:
Lennart Poettering 2024-05-11 13:45:44 +02:00 committed by Yu Watanabe
parent ddbfc4d17e
commit c5ecf09494

View File

@ -134,6 +134,13 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
assert(curl); 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 (timeout_ms < 0) {
if (g->timer) { if (g->timer) {
if (sd_event_source_set_enabled(g->timer, SD_EVENT_OFF) < 0) if (sd_event_source_set_enabled(g->timer, SD_EVENT_OFF) < 0)