]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-ndisc: make the _stop() call idempotent
authorLennart Poettering <lennart@poettering.net>
Mon, 23 May 2016 14:27:59 +0000 (16:27 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 May 2016 13:34:42 +0000 (15:34 +0200)
It's a good idea to make stopcalls idempotent, so that they become nops if the
object is already stopped.

src/libsystemd-network/sd-ndisc.c

index 06afafd2c737f1ef1ce9ab4b1bb23bbbb652dd4d..c03e104e3b04d5345a2fe05991a63ecf2ee8ca05 100644 (file)
@@ -651,12 +651,13 @@ static int ndisc_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
 
 int sd_ndisc_stop(sd_ndisc *nd) {
         assert_return(nd, -EINVAL);
-        assert_return(nd->event, -EINVAL);
 
-        log_ndisc(client, "Stop NDisc");
+        if (nd->state == NDISC_STATE_IDLE)
+                return 0;
+
+        log_ndisc(client, "Stopping IPv6 Router Solicitation client");
 
         ndisc_reset(nd);
-
         nd->state = NDISC_STATE_IDLE;
 
         if (nd->callback)