diff options
-rw-r--r-- | src/alarm.c | 8 | ||||
-rw-r--r-- | src/sync-ftfw.c | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/alarm.c b/src/alarm.c index 25075ef..0fe80ee 100644 --- a/src/alarm.c +++ b/src/alarm.c @@ -31,6 +31,8 @@ void init_alarm(struct alarm_list *t, void *data, void (*fcn)(struct alarm_list *a, void *data)) { + /* initialize the head to check whether a node is inserted */ + INIT_LIST_HEAD(&t->head); timerclear(&t->tv); t->data = data; t->function = fcn; @@ -61,12 +63,14 @@ void add_alarm(struct alarm_list *alarm) void del_alarm(struct alarm_list *alarm) { - list_del(&alarm->head); + /* don't remove a non-inserted node */ + if (!list_empty(&alarm->head)) + list_del_init(&alarm->head); } void mod_alarm(struct alarm_list *alarm, unsigned long sc, unsigned long usc) { - list_del(&alarm->head); + list_del_init(&alarm->head); set_alarm_expiration(alarm, sc, usc); add_alarm(alarm); } diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c index ce58466..11febed 100644 --- a/src/sync-ftfw.c +++ b/src/sync-ftfw.c @@ -274,12 +274,9 @@ static void ftfw_send(struct nethdr *net, struct us_conntrack *u) cn = (struct cache_ftfw *) cache_get_extra(STATE_SYNC(internal), u); - if (cn->rs_list.next == &cn->rs_list && - cn->rs_list.prev == &cn->rs_list) - goto insert; + if (!list_empty(&cn->rs_list) + list_del(&cn->rs_list); - list_del_init(&cn->rs_list); -insert: cn->seq = net->seq; list_add(&cn->rs_list, &rs_list); break; |