static void cleanup_rfc_slot(rfc_slot_t* rs) { APPL_TRACE_DEBUG4("cleanup slot:%d, fd:%d, scn:%d, sdp_handle:0x%x", rs->id, rs->fd, rs->scn, rs->sdp_handle); if(rs->fd != -1) { shutdown(rs->fd, 2); close(rs->fd); rs->fd = -1; } if(rs->app_fd != -1) { close(rs->app_fd); rs->app_fd = -1; } if(rs->sdp_handle > 0) { del_rfc_sdp_rec(rs->sdp_handle); rs->sdp_handle = 0; } if(rs->rfc_handle && !rs->f.closing && !rs->f.server) { APPL_TRACE_DEBUG1("closing rfcomm connection, rfc_handle:0x%x", rs->rfc_handle); BTA_JvRfcommClose(rs->rfc_handle, (void*)rs->id); rs->rfc_handle = 0; } free_rfc_slot_scn(rs); free_gki_que(&rs->incoming_que); rs->rfc_port_handle = 0; //cleanup the flag memset(&rs->f, 0, sizeof(rs->f)); rs->id = 0; }
static void cleanup_l2c_slot(l2c_slot_t* ls) { APPL_TRACE_DEBUG("cleanup slot:%d, fd:%d, psm:%d, sdp_handle:0x%x", ls->id, ls->fd, ls->psm, ls->sdp_handle); if(ls->fd != -1) { shutdown(ls->fd, 2); close(ls->fd); ls->fd = -1; } if(ls->app_fd != -1) { close(ls->app_fd); ls->app_fd = -1; } if(ls->sdp_handle > 0) { del_l2c_sdp_rec(ls->sdp_handle, ls->service_uuid); ls->sdp_handle = 0; } if((ls->l2c_handle != INVALID_L2C_HANDLE) && !ls->f.closing && !ls->f.server) { APPL_TRACE_DEBUG("closing l2cap connection, l2c_handle:0x%x", ls->l2c_handle); BTA_JvL2capClose(ls->l2c_handle, (void*)ls->id); ls->l2c_handle = INVALID_L2C_HANDLE; } free_l2c_slot_psm(ls); free_gki_que(&ls->incoming_que); //cleanup the flag memset(&ls->f, 0, sizeof(ls->f)); ls->in_use = FALSE; }