From: Lennart Poettering Date: Mon, 23 May 2016 14:27:59 +0000 (+0200) Subject: sd-ndisc: make the _stop() call idempotent X-Git-Tag: v231~247^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1c9b211e3337e3491acc5f2550e8d48542986aa;p=thirdparty%2Fsystemd.git sd-ndisc: make the _stop() call idempotent It's a good idea to make stopcalls idempotent, so that they become nops if the object is already stopped. --- diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index 06afafd2c73..c03e104e3b0 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -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)