osmux: Fix CID release for non-enabled connections

Change-Id: If65c70b421476776e20233733722d72aa26d69a8
This commit is contained in:
Pau Espin 2019-05-17 14:38:19 +02:00 committed by Harald Welte
parent 9aaaab6b3b
commit 85978dadab
3 changed files with 15 additions and 15 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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.