From patchwork Thu May 26 12:05:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerrit-no-reply@lists.osmocom.org X-Patchwork-Id: 626645 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3rFnsk5Z5Kz9t4P for ; Thu, 26 May 2016 22:05:46 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id E01821398A; Thu, 26 May 2016 12:05:43 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from 127.0.1.12 (unknown [127.0.1.12]) by lists.osmocom.org (Postfix) with ESMTPA id 23B3B13979; Thu, 26 May 2016 12:05:42 +0000 (UTC) Date: Thu, 26 May 2016 12:05:42 +0000 From: Holger Freyther To: daniel X-Gerrit-MessageType: merged Subject: [MERGED] libosmo-netif[master]: osmux: Add function to delete all msgs pending for a circuit X-Gerrit-Change-Id: Ib0311652183332d0475bf7347023d518d38487ef X-Gerrit-ChangeURL: X-Gerrit-Commit: 2904f82f99fc58538e78bf39900a090da0bcdc3b In-Reply-To: References: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/2.12.2-31-gb331dbd-dirty X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: holger@freyther.de Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Message-Id: <20160526120543.E01821398A@lists.osmocom.org> Holger Freyther has submitted this change and it was merged. Change subject: osmux: Add function to delete all msgs pending for a circuit ...................................................................... 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 --- M src/osmux.c 1 file changed, 11 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved 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); }