summaryrefslogtreecommitdiff
path: root/lib/frr_pthread.c
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2024-02-03 08:40:27 -0500
committerGitHub <noreply@github.com>2024-02-03 08:40:27 -0500
commit3a6c3129ddda3509a9718f1a64341043dc3884ae (patch)
treeb86e74c3ad5a828868320e50b027270bf67f01aa /lib/frr_pthread.c
parent8629700bc8d5629ff57da471d27e0d9fbaf8c5e2 (diff)
parentfdaf08bb46f24cc430ff904c2df3b2321be0d603 (diff)
Merge pull request #15265 from louis-6wind/fix-rpki-logs
bgpd,lib: fix logging from rpki_create_socket()
Diffstat (limited to 'lib/frr_pthread.c')
-rw-r--r--lib/frr_pthread.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index 761969266a..f7e57136d6 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -220,6 +220,37 @@ 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 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_new(NULL);
+ frr_pthread_inner(fpt);
+
+ return 0;
+}
+
/*
* ----------------------------------------------------------------------------
* Default Event Loop