aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-05-17 14:38:19 +0200
committerHarald Welte <laforge@gnumonks.org>2019-05-19 07:31:51 +0000
commit85978dadabca0dd4ee2133470d51d64e1d807cff (patch)
treebcf7e25e15ee0dfe9196eea51b9781b0528cd7ab
parent9aaaab6b3b5a541a6c17077f5f1f8bc00ba77152 (diff)
osmux: Fix CID release for non-enabled connections
-rw-r--r--include/osmocom/mgcp/osmux.h2
-rw-r--r--src/libosmo-mgcp/mgcp_conn.c3
-rw-r--r--src/libosmo-mgcp/mgcp_osmux.c25
3 files changed, 15 insertions, 15 deletions
diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h
index eb0561075..69ba3d043 100644
--- a/include/osmocom/mgcp/osmux.h
+++ b/include/osmocom/mgcp/osmux.h
@@ -14,7 +14,7 @@ enum {
int osmux_init(int role, struct mgcp_config *cfg);
int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
struct in_addr *addr, uint16_t port);
-void osmux_disable_conn(struct mgcp_conn_rtp *conn);
+void conn_osmux_disable(struct mgcp_conn_rtp *conn);
int conn_osmux_allocate_cid(struct mgcp_conn_rtp *conn, int osmux_cid);
void conn_osmux_release_cid(struct mgcp_conn_rtp *conn);
int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 530035140..772584bcd 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -125,7 +125,8 @@ static int mgcp_rtp_conn_init(struct mgcp_conn_rtp *conn_rtp, struct mgcp_conn *
/* Cleanup rtp connection struct */
static void mgcp_rtp_conn_cleanup(struct mgcp_conn_rtp *conn_rtp)
{
- osmux_disable_conn(conn_rtp);
+ if (mgcp_conn_rtp_is_osmux(conn_rtp))
+ conn_osmux_disable(conn_rtp);
mgcp_free_rtp_port(&conn_rtp->end);
rate_ctr_group_free(conn_rtp->rate_ctr_group);
}
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 3b788b642..38657ee74 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -487,26 +487,25 @@ int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
/*! disable OSXMUX circuit for a specified connection.
* \param[in] conn connection to disable */
-void osmux_disable_conn(struct mgcp_conn_rtp *conn)
+void conn_osmux_disable(struct mgcp_conn_rtp *conn)
{
- if (!conn)
- return;
- if (conn->osmux.state != OSMUX_STATE_ENABLED)
- return;
+ OSMO_ASSERT(conn->osmux.state != OSMUX_STATE_DISABLED);
LOGPCONN(conn->conn, DLMGCP, LOGL_INFO,
- "Releasing connection %s using Osmux CID %u\n",
- conn->conn->id, conn->osmux.cid);
+ "Releasing connection using Osmux CID %u\n", conn->osmux.cid);
- /* We are closing, we don't need pending RTP packets to be transmitted */
- osmux_xfrm_output_set_tx_cb(&conn->osmux.out, NULL, NULL);
- osmux_xfrm_output_flush(&conn->osmux.out);
+ if (conn->osmux.state == OSMUX_STATE_ENABLED) {
+ /* We are closing, we don't need pending RTP packets to be transmitted */
+ osmux_xfrm_output_set_tx_cb(&conn->osmux.out, NULL, NULL);
+ osmux_xfrm_output_flush(&conn->osmux.out);
- osmux_xfrm_input_close_circuit(conn->osmux.in, conn->osmux.cid);
- conn->osmux.state = OSMUX_STATE_DISABLED;
+ osmux_xfrm_input_close_circuit(conn->osmux.in, conn->osmux.cid);
+ conn->osmux.state = OSMUX_STATE_DISABLED;
+ conn_osmux_release_cid(conn);
+ osmux_handle_put(conn->osmux.in);
+ }
conn_osmux_release_cid(conn);
- osmux_handle_put(conn->osmux.in);
}
/*! relase OSXMUX cid, that had been allocated to this connection.