From 90304ba081f619db432b5dfb5fb1adbf5d0358c1 Mon Sep 17 00:00:00 2001 From: gilles0606 <38776814+gilles0606@users.noreply.github.com> Date: Sat, 24 Sep 2022 17:25:15 +0200 Subject: [PATCH] Change Thread Create location. Move Thread Create after all direct esl_send_recv. avoid deadlocks. --- libs/esl/fs_cli.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 76e85b450d..86e09972f1 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -1732,12 +1732,6 @@ int main(int argc, char *argv[]) global_handle = &handle; global_profile = profile; - if (esl_thread_create_detached(msg_thread_run, &handle) != ESL_SUCCESS) { - printf("Error starting thread!\n"); - esl_disconnect(&handle); - return 0; - } - snprintf(cmd_str, sizeof(cmd_str), "api switchname\n\n"); esl_send_recv(global_handle, cmd_str); if (global_handle->last_sr_event && global_handle->last_sr_event->body) { @@ -1852,6 +1846,13 @@ int main(int argc, char *argv[]) snprintf(cmd_str, sizeof(cmd_str), "log %s\n\n", profile->loglevel); esl_send_recv(&handle, cmd_str); } + + if (esl_thread_create_detached(msg_thread_run, &handle) != ESL_SUCCESS) { + printf("Error starting thread!\n"); + esl_disconnect(&handle); + return 0; + } + if (global_profile->batch_mode) { setvbuf(stdout, (char*)NULL, _IONBF, 0); }