diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2017-04-03 00:51:20 +0200 | 
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-07-31 03:34:09 +0200 | 
| commit | 3e41733f1bbe9ccd7d08441f5962b3dc6db2c644 (patch) | |
| tree | 1b124e0d8445624aea99d9ce21544bf76e9bec8d /lib/frr_pthread.c | |
| parent | 30ef834ab3b50c09e103a82742b67ae4b0bac9f5 (diff) | |
lib: RCU
Please refer to doc/developer/rcu.rst for documentation.
Signed-off-by: David Lamparter <equinox@diac24.net>
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;  }  | 
