Change in osmo-mgw[master]: osmux: Fix CID release for non-enabled connections

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Sun May 19 17:28:17 UTC 2019


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/14075 )

Change subject: osmux: Fix CID release for non-enabled connections
......................................................................

osmux: Fix CID release for non-enabled connections

Change-Id: If65c70b421476776e20233733722d72aa26d69a8
---
M include/osmocom/mgcp/osmux.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_osmux.c
3 files changed, 15 insertions(+), 15 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h
index eb05610..69ba3d0 100644
--- a/include/osmocom/mgcp/osmux.h
+++ b/include/osmocom/mgcp/osmux.h
@@ -14,7 +14,7 @@
 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 5300351..772584b 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -125,7 +125,8 @@
 /* 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 3b788b6..38657ee 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -487,26 +487,25 @@
 
 /*! 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.

-- 
To view, visit https://gerrit.osmocom.org/14075
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If65c70b421476776e20233733722d72aa26d69a8
Gerrit-Change-Number: 14075
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190519/8a7f0a0b/attachment.html>


More information about the gerrit-log mailing list