From 9ac641d0a674333af57b85b367e64cf94dfae291 Mon Sep 17 00:00:00 2001 From: Matthew Xie Date: Tue, 15 Jan 2013 15:54:03 -0800 Subject: fixed rfc resouce leaking and multi-session issue also added more debug messages bug 7486080 Change-Id: Ic21e9d2df5f651b51ea2126a3cac25811808dcfb --- stack/rfcomm/port_api.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'stack/rfcomm/port_api.c') diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.c index 617d31be0..325d8fa07 100644 --- a/stack/rfcomm/port_api.c +++ b/stack/rfcomm/port_api.c @@ -84,8 +84,6 @@ int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server, tRFC_MCB *p_mcb = port_find_mcb (bd_addr); UINT16 rfcomm_mtu; - RFCOMM_TRACE_API3 ("RFCOMM_CreateConnection() called SCN: %d is_server:%d mtu:%d", - scn, is_server, mtu); RFCOMM_TRACE_API6 ("RFCOMM_CreateConnection() BDA: %02x-%02x-%02x-%02x-%02x-%02x", bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]); @@ -104,6 +102,8 @@ int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server, dlci = (scn << 1) + 1; else dlci = (scn << 1); + RFCOMM_TRACE_API5("RFCOMM_CreateConnection(): scn:%d, dlci:%d, is_server:%d mtu:%d, p_mcb:%p", + scn, dlci, is_server, mtu, p_mcb); /* For the server side always allocate a new port. On the client side */ /* do not allow the same (dlci, bd_addr) to be opened twice by application */ @@ -123,6 +123,8 @@ int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server, RFCOMM_TRACE_WARNING0 ("RFCOMM_CreateConnection - no resources"); return (PORT_NO_RESOURCES); } + RFCOMM_TRACE_API6("RFCOMM_CreateConnection(): scn:%d, dlci:%d, is_server:%d mtu:%d, p_mcb:%p, p_port:%p", + scn, dlci, is_server, mtu, p_mcb, p_port); p_port->default_signal_state = (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON); @@ -309,7 +311,30 @@ int PORT_SetEventCallback (UINT16 port_handle, tPORT_CALLBACK *p_port_cb) return (PORT_SUCCESS); } +/******************************************************************************* +** +** Function PORT_ClearKeepHandleFlag +** +** Description This function is called to clear the keep handle flag +** which will cause not to keep the port handle open when closed +** Parameters: handle - Handle returned in the RFCOMM_CreateConnection +** +*******************************************************************************/ + +int PORT_ClearKeepHandleFlag (UINT16 port_handle) +{ + tPORT *p_port; + /* Check if handle is valid to avoid crashing */ + if ((port_handle == 0) || (port_handle > MAX_RFC_PORTS)) + { + return (PORT_BAD_HANDLE); + } + + p_port = &rfc_cb.port.port[port_handle - 1]; + p_port->keep_port_handle = 0; + return (PORT_SUCCESS); +} /******************************************************************************* ** -- cgit v1.2.3