mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
tools: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f9c863237f
commit
883cd98498
@ -613,9 +613,7 @@ int
|
||||
virFirewallApply(virFirewall *firewall)
|
||||
{
|
||||
size_t i, j;
|
||||
int ret = -1;
|
||||
|
||||
virMutexLock(&ruleLock);
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&ruleLock);
|
||||
|
||||
if (!firewall || firewall->err) {
|
||||
int err = EINVAL;
|
||||
@ -624,7 +622,7 @@ virFirewallApply(virFirewall *firewall)
|
||||
err = firewall->err;
|
||||
|
||||
virReportSystemError(err, "%s", _("Unable to create rule"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Applying groups for %p", firewall);
|
||||
@ -657,13 +655,10 @@ virFirewallApply(virFirewall *firewall)
|
||||
|
||||
virErrorRestore(&saved_error);
|
||||
VIR_DEBUG("Done rolling back groups for %p", firewall);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
VIR_DEBUG("Done applying groups for %p", firewall);
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virMutexUnlock(&ruleLock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
@ -412,13 +412,13 @@ virshDeinit(vshControl *ctl)
|
||||
virResetLastError();
|
||||
|
||||
if (ctl->eventLoopStarted) {
|
||||
int timer;
|
||||
int timer = -1;
|
||||
|
||||
virMutexLock(&ctl->lock);
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&ctl->lock) {
|
||||
ctl->quit = true;
|
||||
/* HACK: Add a dummy timeout to break event loop */
|
||||
timer = virEventAddTimeout(0, virshDeinitTimer, NULL, NULL);
|
||||
virMutexUnlock(&ctl->lock);
|
||||
}
|
||||
|
||||
virThreadJoin(&ctl->eventLoop);
|
||||
|
||||
|
@ -1189,13 +1189,13 @@ vshAdmDeinit(vshControl *ctl)
|
||||
virResetLastError();
|
||||
|
||||
if (ctl->eventLoopStarted) {
|
||||
int timer;
|
||||
int timer = -1;
|
||||
|
||||
virMutexLock(&ctl->lock);
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&ctl->lock) {
|
||||
ctl->quit = true;
|
||||
/* HACK: Add a dummy timeout to break event loop */
|
||||
timer = virEventAddTimeout(0, vshAdmDeinitTimer, NULL, NULL);
|
||||
virMutexUnlock(&ctl->lock);
|
||||
}
|
||||
|
||||
virThreadJoin(&ctl->eventLoop);
|
||||
|
||||
|
@ -2018,10 +2018,10 @@ vshEventLoop(void *opaque)
|
||||
vshControl *ctl = opaque;
|
||||
|
||||
while (1) {
|
||||
bool quit;
|
||||
virMutexLock(&ctl->lock);
|
||||
bool quit = false;
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&ctl->lock) {
|
||||
quit = ctl->quit;
|
||||
virMutexUnlock(&ctl->lock);
|
||||
}
|
||||
|
||||
if (quit)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user