There is no reason why two threads trying to copy error from
connection should mutually exclude each other. Utilize
new virObjectRWLockable that was just introduced.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/datatypes.c | 6 ++++--
src/datatypes.h | 2 +-
src/util/virerror.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index 46414ae29..c3e143c7e 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -83,8 +83,10 @@ virDataTypesOnceInit(void)
DECLARE_CLASS_COMMON(basename, virClassForObject())
#define DECLARE_CLASS_LOCKABLE(basename) \
DECLARE_CLASS_COMMON(basename, virClassForObjectLockable())
+#define DECLARE_CLASS_RWLOCKABLE(basename) \
+ DECLARE_CLASS_COMMON(basename, virClassForObjectRWLockable())
- DECLARE_CLASS_LOCKABLE(virConnect);
+ DECLARE_CLASS_RWLOCKABLE(virConnect);
DECLARE_CLASS_LOCKABLE(virConnectCloseCallbackData);
DECLARE_CLASS(virDomain);
DECLARE_CLASS(virDomainSnapshot);
@@ -124,7 +126,7 @@ virGetConnect(void)
if (virDataTypesInitialize() < 0)
return NULL;
- return virObjectLockableNew(virConnectClass);
+ return virObjectRWLockableNew(virConnectClass);
}
/**
diff --git a/src/datatypes.h b/src/datatypes.h
index 8a0399cd0..7076c2b8d 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -453,7 +453,7 @@ struct _virAdmConnectCloseCallbackData {
* Internal structure associated to a connection
*/
struct _virConnect {
- virObjectLockable object;
+ virObjectRWLockable object;
/* All the variables from here, until declared otherwise in one of
* the following comments, are setup at time of connection open
diff --git a/src/util/virerror.c b/src/util/virerror.c
index ef17fb5e6..fead92d67 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -482,7 +482,7 @@ virConnCopyLastError(virConnectPtr conn, virErrorPtr to)
if (conn == NULL)
return -1;
- virObjectLock(conn);
+ virObjectLockRead(conn);
if (conn->err.code == VIR_ERR_OK)
virResetError(to);
else
--
2.13.0