diff mbox

libosmo-netif[releases/0.0.6-stable]: osmux: Add function to delete all msgs pending for a circuit

Message ID gerrit.1464265151091.Ib0311652183332d0475bf7347023d518d38487ef@gerrit.osmocom.org
State New
Headers show

Commit Message

gerrit-no-reply@lists.osmocom.org May 26, 2016, 12:19 p.m. UTC
Hello Jenkins Builder,

I'd like you to do a code review.  Please visit

    https://gerrit.osmocom.org/122

to review the following change.

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>
---
M src/osmux.c
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/22/122/1

Comments

gerrit-no-reply@lists.osmocom.org May 26, 2016, 12:19 p.m. UTC | #1
Holger Freyther has abandoned this change.

Change subject: osmux: Add function to delete all msgs pending for a circuit
......................................................................


Abandoned

Wanted to push directly
diff mbox

Patch

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 @@ 
 	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 @@ 
 	if (circuit->dummy)
 		batch->ndummy--;
 	llist_del(&circuit->head);
+	osmux_circuit_del_msgs(batch, circuit);
 	talloc_free(circuit);
 }