]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: stop client without calling notification after sending RELEASE
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 01:24:44 +0000 (10:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 02:43:59 +0000 (11:43 +0900)
Otherwise, even the acquired lease is released, the client may be in
e.g. BOUND state or so, and may send renew or rebind after timeout
later.

src/libsystemd-network/sd-dhcp-client.c

index 94ad5bbea9561d7178043c3d222300c6d11e9040..1a1499fa2c960fe8561f5c8acd39886d9f4f5abe 100644 (file)
@@ -2223,7 +2223,11 @@ int sd_dhcp_client_send_release(sd_dhcp_client *client) {
 
         log_dhcp_client(client, "RELEASE");
 
-        return 0;
+        /* This function is mostly called when stopping daemon. Hence, do not call client_stop() or
+         * client_restart(). Otherwise, the notification callback will be called again and we may easily
+         * enter an infinite loop. */
+        client_initialize(client);
+        return 1; /* sent and stopped. */
 }
 
 int sd_dhcp_client_send_decline(sd_dhcp_client *client) {