Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/fix thread schedule loop crash #29

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions framework/common/uv_thread_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ int thread_loop_run(uv_loop_t* loop, bool start_thread, const char* name)
{
loop_priv_t* priv = loop->data;

if (start_thread) {
int ret = uv_sem_init(&priv->ready, 0);
if (ret != 0) {
syslog(LOG_ERR, "%s sem init error: %d", __func__, ret);
return ret;
}
int ret = uv_sem_init(&priv->ready, 0);
if (ret != 0) {
syslog(LOG_ERR, "%s sem init error: %d", __func__, ret);
return ret;
}

if (start_thread) {
uv_thread_options_t options = {
UV_THREAD_HAS_STACK_SIZE | UV_THREAD_HAS_PRIORITY,
LOOP_THREAD_STACK_SIZE,
Expand All @@ -192,14 +192,15 @@ int thread_loop_run(uv_loop_t* loop, bool start_thread, const char* name)
else
snprintf(priv->name, sizeof(priv->name), "loop_%d", getpid());
pthread_setname_np(priv->thread, priv->name);
uv_sem_wait(&priv->ready);
uv_sem_destroy(&priv->ready);
syslog(LOG_DEBUG, "%s loop running now !!!", priv->name);
} else {
syslog(LOG_DEBUG, "%s loop running now !!!", name);
thread_schedule_loop(NULL);
thread_schedule_loop(loop);
}

uv_sem_wait(&priv->ready);
uv_sem_destroy(&priv->ready);

return 0;
}

Expand Down
8 changes: 6 additions & 2 deletions service/profiles/leaudio/tbs/lea_tbs_tele_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,15 @@ static void tbs_call_list_query_complete(tapi_async_result* result)
lea_tbs_call_state_t* state_s = malloc(sizeof(lea_tbs_call_state_t) * result->arg2);
lea_tbs_call_state_t* sub_call;

if (result->status != OK)
if (result->status != OK) {
free(state_s);
return;
}

if (result->arg2 == 0)
if (result->arg2 == 0) {
free(state_s);
return;
}

call_info = result->data;

Expand Down
Loading