diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-09 14:32:44 -0500 | 
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-09 14:38:07 -0500 | 
| commit | 6d0a40b5b76d62d55c68d569579b1eb5a2a3294c (patch) | |
| tree | f6c1584fbf74fb90421615345fcf4ec7ebc09172 /lib/frr_pthread.c | |
| parent | b8dccd94f3d7408812240c375ea9885147300e70 (diff) | |
lib: Cleanup thread name setting to happen at start
When we start a thread we always call fpt_run and since
the last commit we know os_name is filled with something,
therefore we can just set the name on startup.
This creates this output now for zebra:
sharpd@donna ~/frr2> ps -L -p 25643
  PID   LWP TTY          TIME CMD
25643 25643 ?        00:00:00 zebra
25643 25644 ?        00:00:00 Zebra dplane
25643 25684 ?        00:00:00 zebra_apic
sharpd@donna ~/frr2>
I removed the abstraction to frr_pthread_set_name because
it was snprintf'ing into the same buffer which was the
real bug here( the first character of os_name became null).
In the next commit I'll remove that api because
it is unneeded and was a horrible hack to get
this to work for the one place it was wanted.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/frr_pthread.c')
| -rw-r--r-- | lib/frr_pthread.c | 11 | 
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c index 52b85f46d2..c5aec8ca72 100644 --- a/lib/frr_pthread.c +++ b/lib/frr_pthread.c @@ -275,8 +275,15 @@ static void *fpt_run(void *arg)  	fpt->master->handle_signals = false; -	if (fpt->os_name[0]) -		frr_pthread_set_name(fpt, NULL, fpt->os_name); +#ifdef HAVE_PTHREAD_SETNAME_NP +# ifdef GNU_LINUX +	pthread_setname_np(fpt->thread, fpt->os_name); +# else /* NetBSD */ +	pthread_setname_np(fpt->thread, fpt->os_name, NULL); +# endif +#elif defined(HAVE_PTHREAD_SET_NAME_NP) +	pthread_set_name_np(fpt->thread, fpt->os_name); +#endif  	frr_pthread_notify_running(fpt);  | 
