summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocore/write_queue.h1
-rw-r--r--src/write_queue.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/include/osmocore/write_queue.h b/include/osmocore/write_queue.h
index c84000c1..64d4159a 100644
--- a/include/osmocore/write_queue.h
+++ b/include/osmocore/write_queue.h
@@ -38,6 +38,7 @@ struct write_queue {
};
void write_queue_init(struct write_queue *queue, int max_length);
+void write_queue_clear(struct write_queue *queue);
int write_queue_enqueue(struct write_queue *queue, struct msgb *data);
int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what);
diff --git a/src/write_queue.c b/src/write_queue.c
index 7d908b4c..a0ac2d6f 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -72,3 +72,14 @@ int write_queue_enqueue(struct write_queue *queue, struct msgb *data)
return 0;
}
+
+void write_queue_clear(struct write_queue *queue)
+{
+ while (!llist_empty(&queue->msg_queue)) {
+ struct msgb *msg = msgb_dequeue(&queue->msg_queue);
+ msgb_free(msg);
+ }
+
+ queue->current_length = 0;
+ queue->bfd.when &= ~BSC_FD_WRITE;
+}