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

Change-Id: Ife981a4d555f96b63aeaedf27c3ebe513191b0c7
changes/97/13497/1
Harald Welte 4 years ago
parent 00a9673ac2
commit 286a2beaa9
  1. 3
      src/bankd.h
  2. 9
      src/bankd_main.c

@ -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 */

@ -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);

Loading…
Cancel
Save