ch_monitor: Use automatic mutex management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2022-03-25 10:20:08 +01:00
parent 8c6e726f7d
commit 5b48de594d

View File

@ -648,14 +648,13 @@ virCHMonitorCurlPerform(CURL *handle)
int
virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint)
{
VIR_LOCK_GUARD lock = virObjectLockGuard(mon);
g_autofree char *url = NULL;
int responseCode = 0;
int ret = -1;
url = g_strdup_printf("%s/%s", URL_ROOT, endpoint);
virObjectLock(mon);
/* reset all options of a libcurl session handle at first */
curl_easy_reset(mon->handle);
@ -666,8 +665,6 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint)
responseCode = virCHMonitorCurlPerform(mon->handle);
virObjectUnlock(mon);
if (responseCode == 200 || responseCode == 204)
ret = 0;
@ -707,8 +704,7 @@ virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **response
url = g_strdup_printf("%s/%s", URL_ROOT, endpoint);
virObjectLock(mon);
VIR_WITH_OBJECT_LOCK_GUARD(mon) {
/* reset all options of a libcurl session handle at first */
curl_easy_reset(mon->handle);
@ -724,8 +720,7 @@ virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **response
}
responseCode = virCHMonitorCurlPerform(mon->handle);
virObjectUnlock(mon);
}
if (responseCode == 200 || responseCode == 204) {
if (response) {
@ -863,8 +858,7 @@ virCHMonitorCreateVM(virCHMonitor *mon,
nnicindexes, nicindexes) != 0)
return -1;
virObjectLock(mon);
VIR_WITH_OBJECT_LOCK_GUARD(mon) {
/* reset all options of a libcurl session handle at first */
curl_easy_reset(mon->handle);
@ -875,8 +869,7 @@ virCHMonitorCreateVM(virCHMonitor *mon,
curl_easy_setopt(mon->handle, CURLOPT_POSTFIELDS, payload);
responseCode = virCHMonitorCurlPerform(mon->handle);
virObjectUnlock(mon);
}
if (responseCode == 200 || responseCode == 204)
ret = 0;