Skip to content
Snippets Groups Projects
Commit bc6c1e37 authored by Anjan Chanda's avatar Anjan Chanda
Browse files

unlink hlist entries before delete

parent 556c96ec
No related branches found
No related tags found
No related merge requests found
Pipeline #156059 passed
...@@ -20,9 +20,20 @@ ...@@ -20,9 +20,20 @@
#include "cmdu_ackq.h" #include "cmdu_ackq.h"
#define err(...) log_stderr(0, __VA_ARGS__) #define err(...) log_stderr(0, __VA_ARGS__)
#define warn(...) log_stderr(1, __VA_ARGS__)
#define dbg(...) log_stderr(3, __VA_ARGS__) #define dbg(...) log_stderr(3, __VA_ARGS__)
#define loud(...) log_stderr(5, __VA_ARGS__) #define loud(...) log_stderr(5, __VA_ARGS__)
#ifndef warn_on
#define warn_on(condition) \
({ \
int __rc = !!(condition); \
if (__rc) \
warn("%s: WARN '%s'\n", __func__, #condition); \
__rc; \
})
#endif
static int timeradd_msecs(struct timeval *a, unsigned long msecs, static int timeradd_msecs(struct timeval *a, unsigned long msecs,
struct timeval *res) struct timeval *res)
{ {
...@@ -102,10 +113,12 @@ static void cmdu_ackq_delete_msg(struct cmdu_ackq *st, struct cmdu_ackq_entry *m ...@@ -102,10 +113,12 @@ static void cmdu_ackq_delete_msg(struct cmdu_ackq *st, struct cmdu_ackq_entry *m
return; return;
if (msg->cookie) { if (msg->cookie) {
if (st->delete_cb) if (st->delete_cb) {
st->delete_cb(st, msg); st->delete_cb(st, msg);
else } else {
free(msg->cookie); free(msg->cookie);
msg->cookie = NULL;
}
} }
free(msg); free(msg);
...@@ -241,15 +254,23 @@ void cmdu_ackq_flush(void *cmdu_q) ...@@ -241,15 +254,23 @@ void cmdu_ackq_flush(void *cmdu_q)
{ {
struct cmdu_ackq *q = (struct cmdu_ackq *)cmdu_q; struct cmdu_ackq *q = (struct cmdu_ackq *)cmdu_q;
struct cmdu_ackq_entry *msg = NULL; struct cmdu_ackq_entry *msg = NULL;
struct hlist_node *tmp;
int idx = 0; int idx = 0;
for (idx = 0; idx < CMDU_BACKLOG_MAX; idx++) { for (idx = 0; idx < CMDU_BACKLOG_MAX; idx++) {
hlist_for_each_entry(msg, &q->table[idx], hlist) if (hlist_empty(&q->table[idx]))
continue;
hlist_for_each_entry_safe(msg, tmp, &q->table[idx], hlist) {
hlist_del(&msg->hlist, &q->table[idx]);
q->pending_cnt--;
cmdu_ackq_delete_msg(q, msg); cmdu_ackq_delete_msg(q, msg);
}
q->table[idx].first = NULL; q->table[idx].first = NULL;
} }
warn_on(q->pending_cnt != 0);
q->pending_cnt = 0; q->pending_cnt = 0;
} }
......
...@@ -41,6 +41,15 @@ void log_cmdu(uint8_t *buf, size_t len, const char *ifname, bool is_rx); ...@@ -41,6 +41,15 @@ void log_cmdu(uint8_t *buf, size_t len, const char *ifname, bool is_rx);
#define dbg7(fmt, ...) log_message(7, nocl fmt nocl, ## __VA_ARGS__) #define dbg7(fmt, ...) log_message(7, nocl fmt nocl, ## __VA_ARGS__)
#define logcmdu(b,l,i,t) log_cmdu(b,l,i,t) #define logcmdu(b,l,i,t) log_cmdu(b,l,i,t)
#define warn_on(condition) \
({ \
int __rc = !!(condition); \
if (__rc) \
warn("%s: WARN '%s'\n", __func__, #condition); \
__rc; \
})
#else #else
#define err(...) log_message(0, __VA_ARGS__) #define err(...) log_message(0, __VA_ARGS__)
...@@ -54,6 +63,7 @@ void log_cmdu(uint8_t *buf, size_t len, const char *ifname, bool is_rx); ...@@ -54,6 +63,7 @@ void log_cmdu(uint8_t *buf, size_t len, const char *ifname, bool is_rx);
#define dbg7(fmt, ...) log_message(7, __VA_ARGS__) #define dbg7(fmt, ...) log_message(7, __VA_ARGS__)
#define logcmdu(b,l,i,t) #define logcmdu(b,l,i,t)
#define warn_on(condition)
#endif /* DEBUG_COLOR */ #endif /* DEBUG_COLOR */
#endif /* DEBUG_H */ #endif /* DEBUG_H */
...@@ -321,12 +321,16 @@ void neigh_queue_flush(void *nq) ...@@ -321,12 +321,16 @@ void neigh_queue_flush(void *nq)
if (hlist_empty(&q->table[idx])) if (hlist_empty(&q->table[idx]))
continue; continue;
hlist_for_each_entry_safe(e, tmp, &q->table[idx], hlist) hlist_for_each_entry_safe(e, tmp, &q->table[idx], hlist) {
hlist_del(&e->hlist, &q->table[idx]);
q->pending_cnt--;
neigh_entry_delete(e); neigh_entry_delete(e);
}
q->table[idx].first = NULL; q->table[idx].first = NULL;
} }
warn_on(q->pending_cnt != 0);
q->pending_cnt = 0; q->pending_cnt = 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment