summaryrefslogtreecommitdiff
path: root/lib/frr_pthread.c
diff options
context:
space:
mode:
authorDinesh Dutt <5016467+ddutt@users.noreply.github.com>2019-08-12 06:19:54 -0700
committerGitHub <noreply@github.com>2019-08-12 06:19:54 -0700
commit642b081be34f151a6d1bf7bf5c1586bc8561702c (patch)
treee0705cd29d73db5e3df71a57d03ec350af936905 /lib/frr_pthread.c
parentdcc1615e1b5f8f439f01fd9e61845f377d28a07a (diff)
parent595ad74b772ef1e32a1c238e6bc8ae7eb447cd27 (diff)
Merge pull request #1 from FRRouting/master
Merging from upstream tree
Diffstat (limited to 'lib/frr_pthread.c')
-rw-r--r--lib/frr_pthread.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index e588571c01..bdb6c2a397 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -133,18 +133,29 @@ int frr_pthread_set_name(struct frr_pthread *fpt)
return ret;
}
+static void *frr_pthread_inner(void *arg)
+{
+ struct frr_pthread *fpt = arg;
+
+ rcu_thread_start(fpt->rcu_thread);
+ return fpt->attr.start(fpt);
+}
+
int frr_pthread_run(struct frr_pthread *fpt, const pthread_attr_t *attr)
{
int ret;
- ret = pthread_create(&fpt->thread, attr, fpt->attr.start, fpt);
+ fpt->rcu_thread = rcu_thread_prepare();
+ ret = pthread_create(&fpt->thread, attr, frr_pthread_inner, fpt);
/*
* Per pthread_create(3), the contents of fpt->thread are undefined if
* pthread_create() did not succeed. Reset this value to zero.
*/
- if (ret < 0)
+ if (ret < 0) {
+ rcu_thread_unprepare(fpt->rcu_thread);
memset(&fpt->thread, 0x00, sizeof(fpt->thread));
+ }
return ret;
}