Message ID | 1481855291-10212-1-git-send-email-gaohaifeng.gao@huawei.com |
---|---|
State | Accepted |
Headers | show |
On Fri, Dec 16, 2016 at 10:28:11AM +0800, gaohaifeng wrote: > From: zangchuanqiang <zangchuanqiang@huawei.com> > > An alternative "writer nonrecursive" rwlock allows recursive > read-locks to succeed only if there are no threads waiting for the > write-lock. In the function ovs_rwlock_init(), there exist a problem, > the parameter of 'attr' is not used to set the attributes of ovs_rwlock 'l_', > just because use pthread_rwlock_init(&l->lock, NULL) to init l->lock. > > The attr object needs to be passed to the pthread_rwlock_init() > call in order to make use of it. > > Signed-off-by: zangchuanqiang <zangchuanqiang@huawei.com> Oops. Thank you for the fix! I simplified this a bit and applied it to master. I did not backport to it to previous versions due to the risk that this could break otherwise working setups. It looks like this is your first contribution to OVS. Welcome to the team!
diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index aa0aab2..0efc5d5 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -239,8 +239,11 @@ ovs_rwlock_init(const struct ovs_rwlock *l_) #ifdef PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP xpthread_rwlockattr_setkind_np( &attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); -#endif + error = pthread_rwlock_init(&l->lock, &attr); +#else error = pthread_rwlock_init(&l->lock, NULL); +#endif + if (OVS_UNLIKELY(error)) { ovs_abort(error, "pthread_rwlock_init failed"); }