summaryrefslogtreecommitdiffstats
path: root/lib/frr_pthread.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
commit35cadacd2bb9383686753731e31bd7e145fb2506 (patch)
tree4489adbde75a837989533837185b2b8369a0bf68 /lib/frr_pthread.c
parentAdding debian version 9.1-0.1. (diff)
downloadfrr-35cadacd2bb9383686753731e31bd7e145fb2506.tar.xz
frr-35cadacd2bb9383686753731e31bd7e145fb2506.zip
Merging upstream version 10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/frr_pthread.c')
-rw-r--r--lib/frr_pthread.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index c4ead01..1ffa593 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -5,6 +5,9 @@
*/
#include <zebra.h>
+
+#include <signal.h>
+
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
@@ -217,6 +220,41 @@ void frr_pthread_stop_all(void)
}
}
+static void *frr_pthread_attr_non_controlled_start(void *arg)
+{
+ struct frr_pthread *fpt = arg;
+
+ fpt->running = true;
+
+ return NULL;
+}
+
+/* Create a FRR pthread context from a non FRR pthread initialized from an
+ * external library in order to allow logging */
+int frr_pthread_non_controlled_startup(pthread_t thread, const char *name,
+ const char *os_name)
+{
+ struct rcu_thread *rcu_thread = rcu_thread_new(NULL);
+
+ rcu_thread_start(rcu_thread);
+
+ struct frr_pthread_attr attr = {
+ .start = frr_pthread_attr_non_controlled_start,
+ .stop = frr_pthread_attr_default.stop,
+ };
+ struct frr_pthread *fpt;
+
+ fpt = frr_pthread_new(&attr, name, os_name);
+ if (!fpt)
+ return -1;
+
+ fpt->thread = thread;
+ fpt->rcu_thread = rcu_thread;
+ frr_pthread_inner(fpt);
+
+ return 0;
+}
+
/*
* ----------------------------------------------------------------------------
* Default Event Loop