diff --git a/HISTORY b/HISTORY index 1da4714..b0d8acc 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,8 @@ -Version 1.50 2021-04-28 +Version 1.50 2021-04-29 * add function is_digital_string * add function fc_server_load_from_ini_context + * set thread name as necessary Version 1.49 2021-04-17 * add macros: FC_ABS and FC_NEGATIVE diff --git a/src/sched_thread.c b/src/sched_thread.c index cde206a..2205d1e 100644 --- a/src/sched_thread.c +++ b/src/sched_thread.c @@ -17,6 +17,11 @@ #include #include #include + +#ifdef OS_LINUX +#include +#endif + #include "shared_func.h" #include "pthread_func.h" #include "logger.h" @@ -377,6 +382,10 @@ static void *sched_call_func(void *args) TaskFunc task_func; int task_id; +#ifdef OS_LINUX + prctl(PR_SET_NAME, "sched-call"); +#endif + pEntry = (ScheduleEntry *)args; task_func = pEntry->task_func; func_args = pEntry->func_args; @@ -405,6 +414,10 @@ static void *sched_thread_entrance(void *args) int exec_count; int i; +#ifdef OS_LINUX + prctl(PR_SET_NAME, "sched"); +#endif + pContext = (ScheduleContext *)args; if (sched_init_entries(pContext->scheduleArray.entries, pContext->scheduleArray.count) != 0) @@ -852,6 +865,10 @@ static void *sched_call_delay_func(void *args) ScheduleContext *pContext; FastDelayTask *task; +#ifdef OS_LINUX + prctl(PR_SET_NAME, "sched-delay"); +#endif + delay_context = (struct delay_thread_context *)args; task = delay_context->task; pContext = delay_context->schedule_context; diff --git a/src/thread_pool.c b/src/thread_pool.c index ad1a07a..44df87a 100644 --- a/src/thread_pool.c +++ b/src/thread_pool.c @@ -18,6 +18,11 @@ #include #include #include + +#ifdef OS_LINUX +#include +#endif + #include "sched_thread.h" #include "fc_memory.h" #include "thread_pool.h" @@ -36,6 +41,15 @@ static void *thread_entrance(void *arg) thread = (FCThreadInfo *)arg; pool = thread->pool; +#ifdef OS_LINUX + { + char thread_name[64]; + snprintf(thread_name, sizeof(thread_name), "%s[%d]", + pool->name, thread->index); + prctl(PR_SET_NAME, thread_name); + } +#endif + if (pool->extra_data_callbacks.alloc != NULL) { thread->tdata = pool->extra_data_callbacks.alloc(); }