Signed-off-by: Han Han <hhan@redhat.com>
---
src/logging/log_daemon.c | 26 ++++++--------------------
src/logging/log_daemon.h | 4 ++--
2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 028f771f14..0649a70c9d 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -56,7 +56,7 @@
VIR_LOG_INIT("logging.log_daemon");
struct _virLogDaemon {
- virMutex lock;
+ GMutex lock;
virNetDaemonPtr dmn;
virLogHandlerPtr handler;
};
@@ -86,7 +86,7 @@ virLogDaemonFree(virLogDaemonPtr logd)
return;
virObjectUnref(logd->handler);
- virMutexDestroy(&logd->lock);
+ g_mutex_clear(&logd->lock);
virObjectUnref(logd->dmn);
VIR_FREE(logd);
@@ -119,12 +119,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
if (VIR_ALLOC(logd) < 0)
return NULL;
- if (virMutexInit(&logd->lock) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to initialize mutex"));
- VIR_FREE(logd);
- return NULL;
- }
+ g_mutex_init(&logd->lock);
if (!(logd->dmn = virNetDaemonNew()))
goto error;
@@ -222,12 +217,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged,
if (VIR_ALLOC(logd) < 0)
return NULL;
- if (virMutexInit(&logd->lock) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to initialize mutex"));
- VIR_FREE(logd);
- return NULL;
- }
+ g_mutex_init(&logd->lock);
if (!(child = virJSONValueObjectGet(object, "daemon"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -325,7 +315,7 @@ virLogDaemonClientFree(void *opaque)
priv,
(unsigned long long)priv->clientPid);
- virMutexDestroy(&priv->lock);
+ g_mutex_clear(&priv->lock);
VIR_FREE(priv);
}
@@ -343,11 +333,7 @@ virLogDaemonClientNew(virNetServerClientPtr client,
if (VIR_ALLOC(priv) < 0)
return NULL;
- if (virMutexInit(&priv->lock) < 0) {
- VIR_FREE(priv);
- virReportSystemError(errno, "%s", _("unable to init mutex"));
- return NULL;
- }
+ g_mutex_init(&priv->lock);
if (virNetServerClientGetUNIXIdentity(client,
&clientuid,
diff --git a/src/logging/log_daemon.h b/src/logging/log_daemon.h
index fa661e1793..6979bdcd5a 100644
--- a/src/logging/log_daemon.h
+++ b/src/logging/log_daemon.h
@@ -20,7 +20,7 @@
#pragma once
-#include "virthread.h"
+#include <glib.h>
#include "log_handler.h"
typedef struct _virLogDaemon virLogDaemon;
@@ -30,7 +30,7 @@ typedef struct _virLogDaemonClient virLogDaemonClient;
typedef virLogDaemonClient *virLogDaemonClientPtr;
struct _virLogDaemonClient {
- virMutex lock;
+ GMutex lock;
pid_t clientPid;
};
--
2.27.0