提交 2d3c7122 编写于 作者: M Michal Privoznik

Revert "virthread: Introduce virRWLockInitPreferWriter"

This reverts commit 328bd244.

As it turns out, this is not portable and very Linux & glibc
specific. Worse, this may lead to not starving writers on Linux
but everywhere else. Revert this and if the starvation occurs
resolve it.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
上级 bbda2883
......@@ -2733,7 +2733,6 @@ virMutexUnlock;
virOnce;
virRWLockDestroy;
virRWLockInit;
virRWLockInitPreferWriter;
virRWLockRead;
virRWLockUnlock;
virRWLockWrite;
......
......@@ -275,7 +275,7 @@ virObjectRWLockableNew(virClassPtr klass)
if (!(obj = virObjectNew(klass)))
return NULL;
if (virRWLockInitPreferWriter(&obj->lock) < 0) {
if (virRWLockInit(&obj->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to initialize RW lock"));
virObjectUnref(obj);
......
......@@ -95,15 +95,6 @@ void virMutexUnlock(virMutexPtr m)
}
/**
* virRWLockInit:
* @m: rwlock to init
*
* Initializes RW lock using pthread default attributes (which
* is PTHREAD_RWLOCK_PREFER_READER_NP).
*
* Returns 0 on success, -1 otherwise.
*/
int virRWLockInit(virRWLockPtr m)
{
int ret;
......@@ -115,32 +106,6 @@ int virRWLockInit(virRWLockPtr m)
return 0;
}
/**
* virRWLockInitPreferWriter:
* @m: rwlock to init
*
* Initializes RW lock which prefers writers over readers.
*
* Returns 0 on success, -1 otherwise.
*/
int virRWLockInitPreferWriter(virRWLockPtr m)
{
int ret;
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr);
pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
ret = pthread_rwlock_init(&m->lock, &attr);
pthread_rwlockattr_destroy(&attr);
if (ret != 0) {
errno = ret;
return -1;
}
return 0;
}
void virRWLockDestroy(virRWLockPtr m)
{
pthread_rwlock_destroy(&m->lock);
......
......@@ -136,7 +136,6 @@ void virMutexUnlock(virMutexPtr m);
int virRWLockInit(virRWLockPtr m) ATTRIBUTE_RETURN_CHECK;
int virRWLockInitPreferWriter(virRWLockPtr m) ATTRIBUTE_RETURN_CHECK;
void virRWLockDestroy(virRWLockPtr m);
void virRWLockRead(virRWLockPtr m);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册