diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-08-08 08:41:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-08 08:41:07 -0400 |
| commit | 76eb017923497a173815c47cdb6f9852efd5bcb5 (patch) | |
| tree | 5574246fe9b64ef908d40b30e5285068cf6690b8 /lib/frr_pthread.c | |
| parent | 3a738964ec92473c21a5fe75a7fa8de28a344ff8 (diff) | |
| parent | 3e41733f1bbe9ccd7d08441f5962b3dc6db2c644 (diff) | |
Merge pull request #4497 from opensourcerouting/rcu
RCU support
Diffstat (limited to 'lib/frr_pthread.c')
| -rw-r--r-- | lib/frr_pthread.c | 15 |
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; } |
