]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-lldp: accept if a neighbor is already removed from the hashtable
authorLennart Poettering <lennart@poettering.net>
Mon, 17 Dec 2018 17:43:11 +0000 (18:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 18 Dec 2018 10:28:10 +0000 (11:28 +0100)
src/libsystemd-network/lldp-neighbor.c

index 199d8aee0ac4300e379e4370224777a559b41efa..43fc8e03c0701e71cd632b53471d475a2a69afeb 100644 (file)
@@ -82,7 +82,12 @@ sd_lldp_neighbor *lldp_neighbor_unlink(sd_lldp_neighbor *n) {
         if (!n->lldp)
                 return NULL;
 
-        assert_se(hashmap_remove(n->lldp->neighbor_by_id, &n->id) == n);
+        /* Only remove the neighbor object from the hash table if it's in there, don't complain if it isn't. This is
+         * because we are used as destructor call for hashmap_clear() and thus sometimes are called to de-register
+         * ourselves from the hashtable and sometimes are called after we already are de-registered. */
+
+        (void) hashmap_remove_value(n->lldp->neighbor_by_id, &n->id, n);
+
         assert_se(prioq_remove(n->lldp->neighbor_by_expiry, n, &n->prioq_idx) >= 0);
 
         n->lldp = NULL;