aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-22 12:04:36 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-22 12:13:44 +0800
commit569dccf947b36205d9cc156c231016005b277cdb (patch)
tree5701011d543f6c7f329483caf439ca9ac43f979d
parent89a378e9aa017a9b76dbb8d8539cb1abe93dda8a (diff)
nat: Clear the queued messages at the end
It is possible that the calls from the loop would queue more messages for the BSC and then we would have a nice memory leak... Move it to the bottom.
-rw-r--r--openbsc/src/nat/bsc_nat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 623f96f4..0a0a1252 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -437,10 +437,6 @@ static int ipaccess_msc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
static void remove_bsc_connection(struct bsc_connection *connection)
{
struct sccp_connections *sccp_patch, *tmp;
- bsc_unregister_fd(&connection->write_queue.bfd);
- close(connection->write_queue.bfd.fd);
- write_queue_clear(&connection->write_queue);
- llist_del(&connection->list_entry);
/* stop the timeout timer */
bsc_del_timer(&connection->id_timeout);
@@ -457,6 +453,11 @@ static void remove_bsc_connection(struct bsc_connection *connection)
/* close endpoints allocated by this BSC */
bsc_mgcp_clear_endpoints_for(connection);
+ bsc_unregister_fd(&connection->write_queue.bfd);
+ close(connection->write_queue.bfd.fd);
+ write_queue_clear(&connection->write_queue);
+ llist_del(&connection->list_entry);
+
talloc_free(connection);
}