aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2016-05-25 17:44:39 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-05-26 14:13:50 +0200
commitcbb0ad177121ec8f1bc292cfc921c89414790fd5 (patch)
tree95483ecdfb005636f9cb265d02be00e454cd6a9a
parentff4915a2a61def9cd9bb2ae4c2f899263d5cbd89 (diff)
osmux: Add function to delete all msgs pending for a circuit
Use this function in osmux_batch_del_circuit() since msgs are stored in a list per circuit. After the circuit is free()d the msgs are lost. Before this patch any messages enqueued inside a batch when the circiut is deleted were leaking. Change-Id: Ib0311652183332d0475bf7347023d518d38487ef Ticket: OS#1733 Reviewed-on: https://gerrit.osmocom.org/120 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther <holger@freyther.de>
-rw-r--r--src/osmux.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/osmux.c b/src/osmux.c
index 1f5bbe2..0bee9cc 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -225,6 +225,16 @@ static void osmux_batch_dequeue(struct msgb *msg, struct osmux_circuit *circuit)
circuit->nmsgs--;
}
+static void osmux_circuit_del_msgs(struct osmux_batch *batch, struct osmux_circuit *circuit)
+{
+ struct msgb *cur, *tmp;
+ llist_for_each_entry_safe(cur, tmp, &circuit->msg_list, list) {
+ osmux_batch_dequeue(cur, circuit);
+ msgb_free(cur);
+ batch->nmsgs--;
+ }
+}
+
struct osmux_input_state {
struct msgb *out_msg;
struct msgb *msg;
@@ -538,6 +548,7 @@ static void osmux_batch_del_circuit(struct osmux_batch *batch, struct osmux_circ
if (circuit->dummy)
batch->ndummy--;
llist_del(&circuit->head);
+ osmux_circuit_del_msgs(batch, circuit);
talloc_free(circuit);
}