mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
logging: Replace virMutex with GMutex
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Han Han <hhan@redhat.com>
This commit is contained in:
parent
ab5b5f22b9
commit
925e34c71a
@ -56,7 +56,7 @@
|
|||||||
VIR_LOG_INIT("logging.log_daemon");
|
VIR_LOG_INIT("logging.log_daemon");
|
||||||
|
|
||||||
struct _virLogDaemon {
|
struct _virLogDaemon {
|
||||||
virMutex lock;
|
GMutex lock;
|
||||||
virNetDaemonPtr dmn;
|
virNetDaemonPtr dmn;
|
||||||
virLogHandlerPtr handler;
|
virLogHandlerPtr handler;
|
||||||
};
|
};
|
||||||
@ -86,7 +86,7 @@ virLogDaemonFree(virLogDaemonPtr logd)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
virObjectUnref(logd->handler);
|
virObjectUnref(logd->handler);
|
||||||
virMutexDestroy(&logd->lock);
|
g_mutex_clear(&logd->lock);
|
||||||
virObjectUnref(logd->dmn);
|
virObjectUnref(logd->dmn);
|
||||||
|
|
||||||
VIR_FREE(logd);
|
VIR_FREE(logd);
|
||||||
@ -119,12 +119,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
|
|||||||
if (VIR_ALLOC(logd) < 0)
|
if (VIR_ALLOC(logd) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virMutexInit(&logd->lock) < 0) {
|
g_mutex_init(&logd->lock);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Unable to initialize mutex"));
|
|
||||||
VIR_FREE(logd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(logd->dmn = virNetDaemonNew()))
|
if (!(logd->dmn = virNetDaemonNew()))
|
||||||
goto error;
|
goto error;
|
||||||
@ -222,12 +217,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged,
|
|||||||
if (VIR_ALLOC(logd) < 0)
|
if (VIR_ALLOC(logd) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virMutexInit(&logd->lock) < 0) {
|
g_mutex_init(&logd->lock);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Unable to initialize mutex"));
|
|
||||||
VIR_FREE(logd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(child = virJSONValueObjectGet(object, "daemon"))) {
|
if (!(child = virJSONValueObjectGet(object, "daemon"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -325,7 +315,7 @@ virLogDaemonClientFree(void *opaque)
|
|||||||
priv,
|
priv,
|
||||||
(unsigned long long)priv->clientPid);
|
(unsigned long long)priv->clientPid);
|
||||||
|
|
||||||
virMutexDestroy(&priv->lock);
|
g_mutex_clear(&priv->lock);
|
||||||
VIR_FREE(priv);
|
VIR_FREE(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,11 +333,7 @@ virLogDaemonClientNew(virNetServerClientPtr client,
|
|||||||
if (VIR_ALLOC(priv) < 0)
|
if (VIR_ALLOC(priv) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virMutexInit(&priv->lock) < 0) {
|
g_mutex_init(&priv->lock);
|
||||||
VIR_FREE(priv);
|
|
||||||
virReportSystemError(errno, "%s", _("unable to init mutex"));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virNetServerClientGetUNIXIdentity(client,
|
if (virNetServerClientGetUNIXIdentity(client,
|
||||||
&clientuid,
|
&clientuid,
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "virthread.h"
|
|
||||||
#include "log_handler.h"
|
#include "log_handler.h"
|
||||||
|
|
||||||
typedef struct _virLogDaemon virLogDaemon;
|
typedef struct _virLogDaemon virLogDaemon;
|
||||||
@ -30,7 +29,7 @@ typedef struct _virLogDaemonClient virLogDaemonClient;
|
|||||||
typedef virLogDaemonClient *virLogDaemonClientPtr;
|
typedef virLogDaemonClient *virLogDaemonClientPtr;
|
||||||
|
|
||||||
struct _virLogDaemonClient {
|
struct _virLogDaemonClient {
|
||||||
virMutex lock;
|
GMutex lock;
|
||||||
|
|
||||||
pid_t clientPid;
|
pid_t clientPid;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user