aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-07-13 09:57:28 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-07 20:08:15 +0200
commit5b058b65afeccb42d1f309b8f0b93228b29bbdd3 (patch)
treec9855bbda597e0ed987c669a261f2abf58047358
parentc28fc4cd086b99568e2960725bdfce75b16aeee3 (diff)
ganc: destroy peer after read fails or RELEASE has been sent
this is not quite as per spec. We probably need a timer of twice the KEEPALIVE timer of the MS to determine the phone is gone.
-rw-r--r--openbsc/src/osmo-ganc/ganc_server.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/openbsc/src/osmo-ganc/ganc_server.c b/openbsc/src/osmo-ganc/ganc_server.c
index 0ba47f205..444519e1d 100644
--- a/openbsc/src/osmo-ganc/ganc_server.c
+++ b/openbsc/src/osmo-ganc/ganc_server.c
@@ -47,6 +47,15 @@ static void push_rc_csr_hdr(struct msgb *msg, uint8_t pdisc, uint8_t msgt)
gh->msg_type = msgt;
}
+static void gan_peer_destroy(struct gan_peer *peer)
+{
+ if (!peer)
+ return;
+
+ llist_del(&peer->entry);
+ talloc_free(peer);
+}
+
static struct msgb *unc_msgb_alloc(void)
{
return msgb_alloc_headroom(1024+128, 128, "GANC Tx");
@@ -327,6 +336,10 @@ static int rx_rc_deregister(struct gan_peer *peer, struct msgb *msg,
struct tlv_parsed *tp)
{
/* Release all resources, MS will TCP disconnect */
+
+ /* FIXME: not all MS really close the TPC connection, we have to
+ * release the TCP connection locally! */
+ gan_peer_destroy(peer);
return 0;
}
@@ -433,6 +446,7 @@ static int unc_read_cb(struct osmo_conn *conn)
rc = read(conn->queue.bfd.fd, msg->data, 2);
if (rc <= 0) {
msgb_free(msg);
+ gan_peer_destroy(conn->priv);
osmo_conn_close(conn);
return rc;
} else if (rc != 2) {