mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
util: Initialize virLogMutex statically
The only difference is that we are not going to be guaranteed that the mutex is
normal (as opposed to recursive, although there is no system known to me that
would default to recursive mutexes), but that was done only to find occasional
errors (during runtime, back in 2010, commit 336fd879c0
). Functions using
this mutex are mostly stable and unchanging, and it makes the virLogOnceInit()
function only return 0 (or possibly abort in glib calls). On top of that we can
assume that the virLogMutex is always initialized which enables us to be more
consistent in some early error reporting.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
ed5a93e4ed
commit
b863085493
@ -125,7 +125,7 @@ static void virLogOutputToFd(virLogSource *src,
|
|||||||
/*
|
/*
|
||||||
* Logs accesses must be serialized though a mutex
|
* Logs accesses must be serialized though a mutex
|
||||||
*/
|
*/
|
||||||
virMutex virLogMutex;
|
static virMutex virLogMutex = VIR_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
void
|
void
|
||||||
virLogLock(void)
|
virLogLock(void)
|
||||||
@ -250,9 +250,6 @@ virLogPriorityString(virLogPriority lvl)
|
|||||||
static int
|
static int
|
||||||
virLogOnceInit(void)
|
virLogOnceInit(void)
|
||||||
{
|
{
|
||||||
if (virMutexInit(&virLogMutex) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
virLogLock();
|
virLogLock();
|
||||||
virLogDefaultPriority = VIR_LOG_DEFAULT;
|
virLogDefaultPriority = VIR_LOG_DEFAULT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user