network: disable event sources before unref them
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 Sep 2021 08:26:10 +0000 (17:26 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 12 Oct 2021 15:07:35 +0000 (17:07 +0200)
(cherry picked from commit d105befc976ad704d3b17b3a5ee1b659a5f624d4)

src/network/networkd-lldp-tx.c
src/network/networkd-route.c

index 45a087b301c411eef317863ee1fbe858e2fb8b3a..82a403fe21153c392353f1da2d9b13ca56b05b8f 100644 (file)
@@ -413,7 +413,7 @@ int link_lldp_emit_start(Link *link) {
 void link_lldp_emit_stop(Link *link) {
         assert(link);
 
-        link->lldp_emit_event_source = sd_event_source_unref(link->lldp_emit_event_source);
+        link->lldp_emit_event_source = sd_event_source_disable_unref(link->lldp_emit_event_source);
 }
 
 int config_parse_lldp_mud(
index b7852f6eec8bd8868fc2086ce71125857e4f7ab3..791fd64c3993ec96aa2bee2e2b575d1e3e97eed4 100644 (file)
@@ -290,7 +290,7 @@ Route *route_free(Route *route) {
 
         ordered_set_free_with_destructor(route->multipath_routes, multipath_route_free);
 
-        sd_event_source_unref(route->expire);
+        sd_event_source_disable_unref(route->expire);
 
         return mfree(route);
 }
@@ -1273,7 +1273,7 @@ static int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdat
 }
 
 static int route_add_and_setup_timer_one(Link *link, const Route *route, const MultipathRoute *m, const NextHop *nh, uint8_t nh_weight, Route **ret) {
-        _cleanup_(sd_event_source_unrefp) sd_event_source *expire = NULL;
+        _cleanup_(sd_event_source_disable_unrefp) sd_event_source *expire = NULL;
         Route *nr;
         int r;
 
@@ -1311,7 +1311,7 @@ static int route_add_and_setup_timer_one(Link *link, const Route *route, const M
                         return log_link_error_errno(link, r, "Could not arm expiration timer: %m");
         }
 
-        sd_event_source_unref(nr->expire);
+        sd_event_source_disable_unref(nr->expire);
         nr->expire = TAKE_PTR(expire);
 
         *ret = nr;