Skip to content

Commit

Permalink
spp: fix resources are not emptied as SPP profile shutdown
Browse files Browse the repository at this point in the history
bug: v/46456

rootcause: registered not set to 0 as SPP showdown, resulting in
register reach RESGISTER_MAX(5) in spp_register_app.

Change-Id: I8e23a018f313a0ad567e868d8e42fd1001ebc021
Signed-off-by: liuxiang18 <[email protected]>
  • Loading branch information
liuX10 committed Dec 25, 2024
1 parent 0df7598 commit 3fbe031
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service/profiles/spp/spp_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,15 @@ static bt_status_t spp_startup(profile_on_startup_t cb)
}

g_spp_handle.server_channel_map = 0;
g_spp_handle.registered = 0;
g_spp_handle.allocator = index_allocator_create(CONNECTIONS_MAX);
list_initialize(&g_spp_handle.devices);
list_initialize(&g_spp_handle.servers);
list_initialize(&g_spp_handle.apps);
status = bt_sal_spp_init();
if (status != BT_STATUS_SUCCESS) {
pthread_mutex_unlock(&g_spp_handle.spp_lock);
list_delete(&g_spp_handle.devices);
pthread_mutex_unlock(&g_spp_handle.spp_lock);
cb(PROFILE_SPP, false);
return BT_STATUS_FAIL;
}
Expand All @@ -848,6 +849,8 @@ static bt_status_t spp_shutdown(profile_on_shutdown_t cb)
}

g_spp_handle.started = 0;
g_spp_handle.registered = 0;
g_spp_handle.server_channel_map = 0;
spp_cleanup_all_apps();
index_allocator_delete(&g_spp_handle.allocator);
list_delete(&g_spp_handle.devices);
Expand All @@ -872,17 +875,20 @@ static void* spp_register_app(void* remote, const char* name, int port_type, con
pthread_mutex_lock(&g_spp_handle.spp_lock);
if (!g_spp_handle.started) {
pthread_mutex_unlock(&g_spp_handle.spp_lock);
BT_LOGE("%s, SPP not started", __func__);
return NULL;
}

if (g_spp_handle.registered == REGISTER_MAX) {
pthread_mutex_unlock(&g_spp_handle.spp_lock);
BT_LOGE("%s, spp register reach MAX number: %d", __func__, REGISTER_MAX);
return NULL;
}

hdl = zalloc(sizeof(spp_handle_t));
if (hdl == NULL) {
pthread_mutex_unlock(&g_spp_handle.spp_lock);
BT_LOGE("%s, spp handle malloc error", __func__);
return NULL;
}

Expand Down

0 comments on commit 3fbe031

Please sign in to comment.