mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
nwfilter_driver: Statically initialize mutex
This enables a later patch to simplify locking during initialization and cleanup of virNWFilterDriverState. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
991639da96
commit
8c86168868
@ -30,7 +30,6 @@ typedef struct _virNWFilterObjList virNWFilterObjList;
|
|||||||
|
|
||||||
typedef struct _virNWFilterDriverState virNWFilterDriverState;
|
typedef struct _virNWFilterDriverState virNWFilterDriverState;
|
||||||
struct _virNWFilterDriverState {
|
struct _virNWFilterDriverState {
|
||||||
virMutex lock;
|
|
||||||
bool privileged;
|
bool privileged;
|
||||||
|
|
||||||
/* pid file FD, ensures two copies of the driver can't use the same root */
|
/* pid file FD, ensures two copies of the driver can't use the same root */
|
||||||
|
@ -57,13 +57,15 @@ static int nwfilterStateCleanup(void);
|
|||||||
|
|
||||||
static int nwfilterStateReload(void);
|
static int nwfilterStateReload(void);
|
||||||
|
|
||||||
|
static virMutex driverMutex = VIR_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static void nwfilterDriverLock(void)
|
static void nwfilterDriverLock(void)
|
||||||
{
|
{
|
||||||
virMutexLock(&driver->lock);
|
virMutexLock(&driverMutex);
|
||||||
}
|
}
|
||||||
static void nwfilterDriverUnlock(void)
|
static void nwfilterDriverUnlock(void)
|
||||||
{
|
{
|
||||||
virMutexUnlock(&driver->lock);
|
virMutexUnlock(&driverMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_FIREWALLD
|
#ifdef WITH_FIREWALLD
|
||||||
@ -174,10 +176,8 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
driver = g_new0(virNWFilterDriverState, 1);
|
driver = g_new0(virNWFilterDriverState, 1);
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0)
|
|
||||||
goto err_free_driverstate;
|
|
||||||
|
|
||||||
driver->privileged = privileged;
|
driver->privileged = privileged;
|
||||||
|
|
||||||
if (!(driver->nwfilters = virNWFilterObjListNew()))
|
if (!(driver->nwfilters = virNWFilterObjListNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -343,7 +343,6 @@ nwfilterStateCleanup(void)
|
|||||||
/* free inactive nwfilters */
|
/* free inactive nwfilters */
|
||||||
virNWFilterObjListFree(driver->nwfilters);
|
virNWFilterObjListFree(driver->nwfilters);
|
||||||
|
|
||||||
virMutexDestroy(&driver->lock);
|
|
||||||
g_clear_pointer(&driver, g_free);
|
g_clear_pointer(&driver, g_free);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user