[PATCH] libosmocore[master]: write_queue: implement overflow handling by dropping the old...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Dec 5 14:59:15 UTC 2016


Review at  https://gerrit.osmocom.org/1362

write_queue: implement overflow handling by dropping the oldest msgb

When a new element should be inserted into a full write queue, drop the oldest
message in queue.

Change-Id: Ica7d0a1f2bd7d9da238c8cac0686db78bcfd48f1
---
M src/write_queue.c
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/1362/1

diff --git a/src/write_queue.c b/src/write_queue.c
index 3e488ae..5aa2307 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -104,8 +104,14 @@
  */
 int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
 {
-//	if (queue->current_length + 1 >= queue->max_length)
-//		LOGP(DMSC, LOGL_ERROR, "The queue is full. Dropping not yet implemented.\n");
+	if (queue->current_length + 1 >= queue->max_length) {
+		struct llist_head *first = queue->msg_queue.next;
+		struct msgb* = container_of(first, struct msgb, list);
+		llist_del(queue->msg_queue.next);
+		msgb_free(first);
+		/* FIXME: this should be a rate limit warnin or error */
+		LOGP(DMSC, LOGL_DEBUG, "The queue is full. Dropping last package.\n");
+	}
 
 	++queue->current_length;
 	msgb_enqueue(&queue->msg_queue, data);

-- 
To view, visit https://gerrit.osmocom.org/1362
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica7d0a1f2bd7d9da238c8cac0686db78bcfd48f1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list