fixed rpl-classic bug and moved the two lifetime loops into one
This commit is contained in:
parent
cbdc3e4569
commit
a5039634d5
@ -203,9 +203,11 @@ void
|
|||||||
rpl_ns_periodic(void)
|
rpl_ns_periodic(void)
|
||||||
{
|
{
|
||||||
rpl_ns_node_t *l;
|
rpl_ns_node_t *l;
|
||||||
|
rpl_ns_node_t *next;
|
||||||
|
|
||||||
/* First pass, for all expired nodes, deallocate them iff no child points to them */
|
/* First pass, for all expired nodes, deallocate them iff no child points to them */
|
||||||
for(l = list_head(nodelist); l != NULL; l = list_item_next(l)) {
|
for(l = list_head(nodelist); l != NULL; l = next) {
|
||||||
|
next = list_item_next(l);
|
||||||
if(l->lifetime == 0) {
|
if(l->lifetime == 0) {
|
||||||
rpl_ns_node_t *l2;
|
rpl_ns_node_t *l2;
|
||||||
for(l2 = list_head(nodelist); l2 != NULL; l2 = list_item_next(l2)) {
|
for(l2 = list_head(nodelist); l2 != NULL; l2 = list_item_next(l2)) {
|
||||||
@ -217,13 +219,8 @@ rpl_ns_periodic(void)
|
|||||||
list_remove(nodelist, l);
|
list_remove(nodelist, l);
|
||||||
memb_free(&nodememb, l);
|
memb_free(&nodememb, l);
|
||||||
num_nodes--;
|
num_nodes--;
|
||||||
}
|
} else if(l->lifetime != 0xffffffff) {
|
||||||
}
|
/* Decrement lifetime for all nodes with non-infinite lifetime */
|
||||||
|
|
||||||
/* Second pass, decrement lifetime for all nodes with non-infinite lifetime */
|
|
||||||
for(l = list_head(nodelist); l != NULL; l = list_item_next(l)) {
|
|
||||||
/* Don't touch infinite lifetime nodes */
|
|
||||||
if(l->lifetime != 0xffffffff && l->lifetime > 0) {
|
|
||||||
l->lifetime--;
|
l->lifetime--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,13 +229,7 @@ rpl_ns_periodic(unsigned seconds)
|
|||||||
list_remove(nodelist, l);
|
list_remove(nodelist, l);
|
||||||
memb_free(&nodememb, l);
|
memb_free(&nodememb, l);
|
||||||
num_nodes--;
|
num_nodes--;
|
||||||
}
|
} else if(l->lifetime != RPL_ROUTE_INFINITE_LIFETIME) {
|
||||||
}
|
|
||||||
|
|
||||||
/* Second pass, decrement lifetime for all nodes with non-infinite lifetime */
|
|
||||||
for(l = list_head(nodelist); l != NULL; l = list_item_next(l)) {
|
|
||||||
/* Don't touch infinite lifetime nodes */
|
|
||||||
if(l->lifetime != RPL_ROUTE_INFINITE_LIFETIME) {
|
|
||||||
l->lifetime = l->lifetime > seconds ? l->lifetime - seconds : 0;
|
l->lifetime = l->lifetime > seconds ? l->lifetime - seconds : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user