summaryrefslogtreecommitdiffstats
path: root/lib/thread.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-03-05 23:58:22 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-03-06 00:04:54 +0100
commitd8a8a8de00ca28879eb865cd4f25e362570a910e (patch)
tree3c49c8db31e59357dc3a22e7ae2ba816931ec4d2 /lib/thread.c
parentMerge pull request #1784 from donaldsharp/documentation (diff)
downloadfrr-d8a8a8de00ca28879eb865cd4f25e362570a910e.tar.xz
frr-d8a8a8de00ca28879eb865cd4f25e362570a910e.zip
lib: some frr_pthread fixes
* Use atomic fixed-width thread identifiers * Add ability to change thread name at runtime Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/thread.c b/lib/thread.c
index 9d64663d9..868bfd0e9 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -343,7 +343,6 @@ static void initializer()
pthread_key_create(&thread_current, NULL);
}
-/* Allocate new thread master. */
struct thread_master *thread_master_create(const char *name)
{
struct thread_master *rv;
@@ -427,6 +426,17 @@ struct thread_master *thread_master_create(const char *name)
return rv;
}
+void thread_master_set_name(struct thread_master *master, const char *name)
+{
+ pthread_mutex_lock(&master->mtx);
+ {
+ if (master->name)
+ XFREE(MTYPE_THREAD_MASTER, master->name);
+ master->name = XSTRDUP(MTYPE_THREAD_MASTER, name);
+ }
+ pthread_mutex_unlock(&master->mtx);
+}
+
/* Add a new thread to the list. */
static void thread_list_add(struct thread_list *list, struct thread *thread)
{