From 1f9eb3d62c78bae8b429a48f71629d6e53f9fc87 Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Wed, 25 May 2016 18:08:29 -0700 Subject: [PATCH] Remove the RFComm MCB from the ports when releasing it Bug: 28849621 Change-Id: I3ce1c857d0d0a2c00c59d8f71b40685ae602dc29 --- stack/rfcomm/port_rfc.c | 1 - stack/rfcomm/rfc_utils.c | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.c index fb9a14624..aaad62ab8 100644 --- a/stack/rfcomm/port_rfc.c +++ b/stack/rfcomm/port_rfc.c @@ -228,7 +228,6 @@ void PORT_StartCnf (tRFC_MCB *p_mcb, UINT16 result) p_port->error = PORT_START_FAILED; rfc_release_multiplexer_channel (p_mcb); - p_port->rfc.p_mcb = NULL; /* Send event to the application */ if (p_port->p_callback && (p_port->ev_mask & PORT_EV_CONNECT_ERR)) diff --git a/stack/rfcomm/rfc_utils.c b/stack/rfcomm/rfc_utils.c index e705f0d5d..2fa7ca826 100644 --- a/stack/rfcomm/rfc_utils.c +++ b/stack/rfcomm/rfc_utils.c @@ -198,8 +198,7 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator) ** ** Function rfc_release_multiplexer_channel ** -** Description This function returns existing or new control block for -** the BD_ADDR. +** Description Release a multiplexer control block ** *******************************************************************************/ void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb) @@ -207,6 +206,12 @@ void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb) /* Remove the MCB from the mapping table */ rfc_save_lcid_mcb(NULL, p_mcb->lcid); + /* Remove the MCB from the ports */ + for (int i = 0; i < MAX_RFC_PORTS; i++) { + if (rfc_cb.port.port[i].rfc.p_mcb == p_mcb) + rfc_cb.port.port[i].rfc.p_mcb = NULL; + } + rfc_timer_stop (p_mcb); alarm_free(p_mcb->mcb_timer); -- 2.11.0