mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 01:40:16 +00:00
Merge pull request #3590 from donaldsharp/zebra_pthread_setnames
FRR pthread setnames
This commit is contained in:
commit
c065db320a
@ -181,7 +181,11 @@ void *bgp_keepalives_start(void *arg)
|
|||||||
pthread_cond_init(peerhash_cond, &attrs);
|
pthread_cond_init(peerhash_cond, &attrs);
|
||||||
pthread_condattr_destroy(&attrs);
|
pthread_condattr_destroy(&attrs);
|
||||||
|
|
||||||
frr_pthread_set_name(fpt, NULL, "bgpd_ka");
|
/*
|
||||||
|
* We are not using normal FRR pthread mechanics and are
|
||||||
|
* not using fpt_run
|
||||||
|
*/
|
||||||
|
frr_pthread_set_name(fpt);
|
||||||
|
|
||||||
/* initialize peer hashtable */
|
/* initialize peer hashtable */
|
||||||
peerhash = hash_create_size(2048, peer_hash_key, peer_hash_cmp, NULL);
|
peerhash = hash_create_size(2048, peer_hash_key, peer_hash_cmp, NULL);
|
||||||
|
@ -84,6 +84,8 @@ struct frr_pthread *frr_pthread_new(struct frr_pthread_attr *attr,
|
|||||||
fpt->name = XSTRDUP(MTYPE_FRR_PTHREAD, name);
|
fpt->name = XSTRDUP(MTYPE_FRR_PTHREAD, name);
|
||||||
if (os_name)
|
if (os_name)
|
||||||
snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", os_name);
|
snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", os_name);
|
||||||
|
else
|
||||||
|
snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", name);
|
||||||
/* initialize startup synchronization primitives */
|
/* initialize startup synchronization primitives */
|
||||||
fpt->running_cond_mtx = XCALLOC(
|
fpt->running_cond_mtx = XCALLOC(
|
||||||
MTYPE_PTHREAD_PRIM, sizeof(pthread_mutex_t));
|
MTYPE_PTHREAD_PRIM, sizeof(pthread_mutex_t));
|
||||||
@ -115,26 +117,10 @@ void frr_pthread_destroy(struct frr_pthread *fpt)
|
|||||||
XFREE(MTYPE_FRR_PTHREAD, fpt);
|
XFREE(MTYPE_FRR_PTHREAD, fpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
|
int frr_pthread_set_name(struct frr_pthread *fpt)
|
||||||
const char *os_name)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (name) {
|
|
||||||
pthread_mutex_lock(&fpt->mtx);
|
|
||||||
{
|
|
||||||
if (fpt->name)
|
|
||||||
XFREE(MTYPE_FRR_PTHREAD, fpt->name);
|
|
||||||
fpt->name = XSTRDUP(MTYPE_FRR_PTHREAD, name);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&fpt->mtx);
|
|
||||||
thread_master_set_name(fpt->master, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (os_name) {
|
|
||||||
pthread_mutex_lock(&fpt->mtx);
|
|
||||||
snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", os_name);
|
|
||||||
pthread_mutex_unlock(&fpt->mtx);
|
|
||||||
#ifdef HAVE_PTHREAD_SETNAME_NP
|
#ifdef HAVE_PTHREAD_SETNAME_NP
|
||||||
# ifdef GNU_LINUX
|
# ifdef GNU_LINUX
|
||||||
ret = pthread_setname_np(fpt->thread, fpt->os_name);
|
ret = pthread_setname_np(fpt->thread, fpt->os_name);
|
||||||
@ -144,7 +130,6 @@ int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
|
|||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
||||||
pthread_set_name_np(fpt->thread, fpt->os_name);
|
pthread_set_name_np(fpt->thread, fpt->os_name);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -273,8 +258,7 @@ static void *fpt_run(void *arg)
|
|||||||
|
|
||||||
fpt->master->handle_signals = false;
|
fpt->master->handle_signals = false;
|
||||||
|
|
||||||
if (fpt->os_name[0])
|
frr_pthread_set_name(fpt);
|
||||||
frr_pthread_set_name(fpt, NULL, fpt->os_name);
|
|
||||||
|
|
||||||
frr_pthread_notify_running(fpt);
|
frr_pthread_notify_running(fpt);
|
||||||
|
|
||||||
|
@ -133,16 +133,13 @@ struct frr_pthread *frr_pthread_new(struct frr_pthread_attr *attr,
|
|||||||
const char *name, const char *os_name);
|
const char *name, const char *os_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes the name of the frr_pthread.
|
* Changes the name of the frr_pthread as reported by the operating
|
||||||
|
* system.
|
||||||
*
|
*
|
||||||
* @param fpt - the frr_pthread to operate on
|
* @param fpt - the frr_pthread to operate on
|
||||||
* @param name - Human-readable name
|
|
||||||
* @param os_name - 16 characters thread name , including the null
|
|
||||||
* terminator ('\0') to set in os.
|
|
||||||
* @return - on success returns 0 otherwise nonzero error number.
|
* @return - on success returns 0 otherwise nonzero error number.
|
||||||
*/
|
*/
|
||||||
int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
|
int frr_pthread_set_name(struct frr_pthread *fpt);
|
||||||
const char *os_name);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroys an frr_pthread.
|
* Destroys an frr_pthread.
|
||||||
|
Loading…
Reference in New Issue
Block a user