bandk: store the worker name as part of 'struct bankd_worker'

Change-Id: Ife981a4d555f96b63aeaedf27c3ebe513191b0c7
This commit is contained in:
Harald Welte 2019-03-11 17:36:58 +01:00
parent 00a9673ac2
commit 286a2beaa9
2 changed files with 7 additions and 5 deletions

View File

@ -46,6 +46,9 @@ struct bankd_worker {
/* back-pointer to bankd */
struct bankd *bankd;
/* name of the worker */
char *name;
/* thread number */
unsigned int num;
/* worker thread state */

View File

@ -698,14 +698,9 @@ static void *worker_main(void *arg)
{
void *top_ctx;
int rc;
char worker_name[32];
g_worker = (struct bankd_worker *) arg;
/* set the thread name */
snprintf(worker_name, sizeof(worker_name), "bankd-worker(%u)", g_worker->num);
pthread_setname_np(pthread_self(), worker_name);
worker_set_state(g_worker, BW_ST_INIT);
/* not permitted in multithreaded environment */
@ -713,6 +708,10 @@ static void *worker_main(void *arg)
top_ctx = talloc_named_const(NULL, 0, "top");
talloc_asn1_ctx = talloc_named_const(top_ctx, 0, "asn1");
/* set the thread name */
g_worker->name = talloc_asprintf(g_worker->tall_ctx, "bankd-worker(%u)", g_worker->num);
pthread_setname_np(pthread_self(), g_worker->name);
/* push cleanup helper */
pthread_cleanup_push(&worker_cleanup, g_worker);