]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd-network: do not request each daemon exist in sd_xxx_stop()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Oct 2020 22:24:17 +0000 (07:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Oct 2020 22:24:17 +0000 (07:24 +0900)
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-server.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-ipv4acd.c
src/libsystemd-network/sd-ipv4ll.c
src/libsystemd-network/sd-lldp.c
src/libsystemd-network/sd-ndisc.c
src/libsystemd-network/sd-radv.c

index 6eb3c1b7a0cedca44b031449bb38f56f65dfd54a..53c43508749a7e472644799e3f4b1c5c079e01ef 100644 (file)
@@ -2135,9 +2135,10 @@ int sd_dhcp_client_send_decline(sd_dhcp_client *client) {
 }
 
 int sd_dhcp_client_stop(sd_dhcp_client *client) {
-        DHCP_CLIENT_DONT_DESTROY(client);
+        if (!client)
+                return 0;
 
-        assert_return(client, -EINVAL);
+        DHCP_CLIENT_DONT_DESTROY(client);
 
         client_stop(client, SD_DHCP_CLIENT_EVENT_STOP);
         client->state = DHCP_STATE_STOPPED;
index a34a55919e2dd90f4eac7c3c1122b8d739e12009..9022aefccb2395574b50b3ebed3494f2f44033a1 100644 (file)
@@ -225,7 +225,8 @@ sd_event *sd_dhcp_server_get_event(sd_dhcp_server *server) {
 }
 
 int sd_dhcp_server_stop(sd_dhcp_server *server) {
-        assert_return(server, -EINVAL);
+        if (!server)
+                return 0;
 
         server->receive_message =
                 sd_event_source_unref(server->receive_message);
index e1dbdaff4e78695315b23e80087f21c5f7b78844..6d27c4685eddd030cc03357ab0d2c41ab3e07d6d 100644 (file)
@@ -1676,7 +1676,8 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state) {
 }
 
 int sd_dhcp6_client_stop(sd_dhcp6_client *client) {
-        assert_return(client, -EINVAL);
+        if (!client)
+                return 0;
 
         client_stop(client, SD_DHCP6_CLIENT_EVENT_STOP);
 
index ecd91cd927cd1f412ccd68c7f888492eaf5d5e59..ff333914e903e8c6db864721d1345face59aeb7a 100644 (file)
@@ -144,7 +144,8 @@ static void ipv4acd_client_notify(sd_ipv4acd *acd, int event) {
 int sd_ipv4acd_stop(sd_ipv4acd *acd) {
         IPv4ACDState old_state;
 
-        assert_return(acd, -EINVAL);
+        if (!acd)
+                return 0;
 
         old_state = acd->state;
 
index 4f4d9ebe87719add28630b590dcc4057f4d61349..293a4644a23b8fbbddf15a410d729a63aa76108f 100644 (file)
@@ -89,7 +89,8 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
 }
 
 int sd_ipv4ll_stop(sd_ipv4ll *ll) {
-        assert_return(ll, -EINVAL);
+        if (!ll)
+                return 0;
 
         return sd_ipv4acd_stop(ll->acd);
 }
index b0a11fe20b618822a573b7b690fe5e711eef6f83..e536f90d19478ba14db4091ea09bebbd7ab430d0 100644 (file)
@@ -276,7 +276,8 @@ fail:
 }
 
 _public_ int sd_lldp_stop(sd_lldp *lldp) {
-        assert_return(lldp, -EINVAL);
+        if (!lldp)
+                return 0;
 
         if (lldp->fd < 0)
                 return 0;
index 9922203ac4be88002c91d7e2ca06eb344b925634..92e772d352fc2a64b95620ed9b62d16f73d81d5a 100644 (file)
@@ -321,7 +321,8 @@ static int ndisc_timeout_no_ra(sd_event_source *s, uint64_t usec, void *userdata
 }
 
 _public_ int sd_ndisc_stop(sd_ndisc *nd) {
-        assert_return(nd, -EINVAL);
+        if (!nd)
+                return 0;
 
         if (nd->fd < 0)
                 return 0;
index 016808667cf3ab0fcfb5518ab3ca07fce1b0a466..9656d7c969ce9ca44d0369cdaba2d705900ddd36 100644 (file)
@@ -353,7 +353,8 @@ fail:
 _public_ int sd_radv_stop(sd_radv *ra) {
         int r;
 
-        assert_return(ra, -EINVAL);
+        if (!ra)
+                return 0;
 
         if (ra->state == SD_RADV_STATE_IDLE)
                 return 0;