diff options
author | zangchuanqiang <zangchuanqiang@huawei.com> | 2016-12-16 10:28:11 +0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-12-22 16:21:01 -0800 |
commit | 1a15f390afd66efd161db78b86600832214dfb3c (patch) | |
tree | d0091ca29fddd3c7c1be6dcc751064d94c6a8edf /lib | |
parent | c4817da780613cf4bfd77694bf859ad96d99b93c (diff) | |
download | openvswitch-1a15f390afd66efd161db78b86600832214dfb3c.tar.gz |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ovs-thread.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index aa0aab291..058c434f5 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -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"); } |