mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Revert "virthread: Introduce virRWLockInitPreferWriter"
This reverts commit 328bd24443
.
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: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
bbda2883c4
commit
2d3c7122c8
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user