2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-03 15:55:19 +00:00

lib/ovs-thread: set prefer writer lock for ovs_rwlock_init()

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>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
zangchuanqiang
2016-12-16 10:28:11 +08:00
committed by Ben Pfaff
parent c4817da780
commit 1a15f390af
2 changed files with 2 additions and 1 deletions

View File

@@ -309,6 +309,7 @@ nickcooper-zhangtonghao nickcooper-zhangtonghao@opencloud.tech
wisd0me ak47izatool@gmail.com
xushengping shengping.xu@huawei.com
yinpeijun yinpeijun@huawei.com
zangchuanqiang zangchuanqiang@huawei.com
=============================== ===============================================
The following additional people are mentioned in commit logs as having

View File

@@ -240,7 +240,7 @@ ovs_rwlock_init(const struct ovs_rwlock *l_)
xpthread_rwlockattr_setkind_np(
&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#endif
error = pthread_rwlock_init(&l->lock, NULL);
error = pthread_rwlock_init(&l->lock, &attr);
if (OVS_UNLIKELY(error)) {
ovs_abort(error, "pthread_rwlock_init failed");
}