[PATCH] osmo-bsc[master]: mgcp: cancel transactions on timeout

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Dec 4 11:10:33 UTC 2017


Review at  https://gerrit.osmocom.org/5157

mgcp: cancel transactions on timeout

when a transaction to the MGW times out, then the context
information is freed. Unfortunately the client is not informed
about this and will try to execute the callback anyway.

explicitly cancel the transaction in order to prevent access
to already freed data structures.

Change-Id: I40794dff7d10e2b6a96863a2da7e9fbd5662a1bf
---
M include/osmocom/bsc/osmo_bsc_mgcp.h
M src/osmo-bsc/osmo_bsc_mgcp.c
2 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/57/5157/1

diff --git a/include/osmocom/bsc/osmo_bsc_mgcp.h b/include/osmocom/bsc/osmo_bsc_mgcp.h
index df18524..f7106b6 100644
--- a/include/osmocom/bsc/osmo_bsc_mgcp.h
+++ b/include/osmocom/bsc/osmo_bsc_mgcp.h
@@ -21,6 +21,7 @@
 #pragma once
 
 #include <osmocom/mgcp_client/mgcp_common.h>
+#include <osmocom/mgcp_client/mgcp_client.h>
 
 /* MGCP state handler context (fsm etc..) */
 struct mgcp_ctx {
@@ -43,6 +44,7 @@
 	struct gsm_lchan *lchan;
 	struct gsm_lchan *ho_lchan;
 	struct msgb *resp;
+	mgcp_trans_id_t mgw_pending_trans;
 };
 
 struct mgcp_ctx *mgcp_assignm_req(void *ctx, struct mgcp_client *mgcp, struct osmo_bsc_sccp_con *conn,
diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
index f5efa95..39ae9d0 100644
--- a/src/osmo-bsc/osmo_bsc_mgcp.c
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -182,6 +182,7 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
+	mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
 	rc = mgcp_client_tx(mgcp, msg, crcx_for_bts_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
@@ -335,6 +336,7 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
+	mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
 	rc = mgcp_client_tx(mgcp, msg, mdcx_for_bts_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
@@ -460,6 +462,7 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
+	mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
 	rc = mgcp_client_tx(mgcp, msg, crcx_for_net_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
@@ -595,6 +598,7 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
+	mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
 	rc = mgcp_client_tx(mgcp, msg, dlcx_for_all_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
@@ -652,6 +656,8 @@
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
+	/* Transmit MGCP message to MGW */
+	mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
 	rc = mgcp_client_tx(mgcp, msg, mdcx_for_bts_ho_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
@@ -815,6 +821,9 @@
 		/* At least release the occupied endpoint ID */
 		mgcp_client_release_endpoint(mgcp_ctx->rtp_endpoint, mgcp);
 
+		/* Cancel the transaction that timed out */
+		mgcp_client_cancel(mgcp, mgcp_ctx->mgw_pending_trans);
+
 		/* Initiate self destruction of the FSM */
 		osmo_fsm_inst_state_chg(fi, ST_HALT, 0, 0);
 		osmo_fsm_inst_dispatch(fi, EV_TEARDOWN, mgcp_ctx);

-- 
To view, visit https://gerrit.osmocom.org/5157
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40794dff7d10e2b6a96863a2da7e9fbd5662a1bf
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list