This reverts commit 328bd24443d2a345a5832ee48ebba0208f8036ea.
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(a)redhat.com>
---
src/libvirt_private.syms | 1 -
src/util/virobject.c | 2 +-
src/util/virthread.c | 35 -----------------------------------
src/util/virthread.h | 1 -
4 files changed, 1 insertion(+), 38 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3cc6f4c6e..d98417678 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2733,7 +2733,6 @@ virMutexUnlock;
virOnce;
virRWLockDestroy;
virRWLockInit;
-virRWLockInitPreferWriter;
virRWLockRead;
virRWLockUnlock;
virRWLockWrite;
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 4236abfef..b1bb378b4 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -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);
diff --git a/src/util/virthread.c b/src/util/virthread.c
index a8dd72f8b..6c495158f 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -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);
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 18b785af2..e466d9bf0 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -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);
--
2.13.0