diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2015-11-24 13:32:23 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2015-12-03 11:39:55 +0100 |
commit | 1aa0e47104d9529ecf448b81adb9ef6fb0a50c5f (patch) | |
tree | 4bdb03c06dce865cd2378600200c3941228081a6 /openbsc/src/gprs/gtphub.c | |
parent | 508514c7c5a4cc2d4eae27a7e6df80b10ec4e863 (diff) |
gtphub: add assertion to ensure expiry ordering.
Make 100% sure the user adds expiring_items in chronological order by asserting
that a newly added expiry is >= the last expiry in the queue. Add llist_last()
to facilitate.
Sponsored-by: On-Waves ehi
Diffstat (limited to 'openbsc/src/gprs/gtphub.c')
-rw-r--r-- | openbsc/src/gprs/gtphub.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index 0550c7ffe..e339ac69b 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -62,6 +62,10 @@ typedef int (*osmo_fd_cb_t)(struct osmo_fd *fd, unsigned int what); #define llist_first(head, type, entry) \ llist_entry(__llist_first(head), type, entry) +#define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) +#define llist_last(head, type, entry) \ + llist_entry(__llist_last(head), type, entry) + /* TODO move GTP header stuff to openggsn/gtp/ ? See gtp_decaps*() */ enum gtp_rc { @@ -564,6 +568,10 @@ void expiry_add(struct expiry *exq, struct expiring_item *item, time_t now) { item->expiry = now + exq->expiry_in_seconds; + OSMO_ASSERT(llist_empty(&exq->items) + || (item->expiry + >= llist_last(&exq->items, struct expiring_item, entry)->expiry)); + /* Add/move to the tail to always sort by expiry, ascending. */ llist_del(&item->entry); llist_add_tail(&item->entry, &exq->items); |