diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index f57a8d5f25..e6e92c7dc4 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -452,8 +452,9 @@ static void qemuAgentUnregister(qemuAgent *agent) { if (agent->watch) { + g_source_destroy(agent->watch); vir_g_source_unref(agent->watch, agent->context); - g_clear_pointer(&agent->watch, g_source_destroy); + agent->watch = NULL; } } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 37bcbde31e..32c993a941 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -794,8 +794,9 @@ void qemuMonitorUnregister(qemuMonitor *mon) { if (mon->watch) { + g_source_destroy(mon->watch); vir_g_source_unref(mon->watch, mon->context); - g_clear_pointer(&mon->watch, g_source_destroy); + mon->watch = NULL; } } diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c index fc04d8f712..983787932f 100644 --- a/src/util/vireventglib.c +++ b/src/util/vireventglib.c @@ -228,7 +228,8 @@ virEventGLibHandleUpdate(int watch, VIR_DEBUG("Removed old handle source=%p", data->source); g_source_destroy(data->source); - g_clear_pointer(&data->source, g_source_destroy); + vir_g_source_unref(data->source, NULL); + data->source = NULL; data->events = 0; } @@ -275,8 +276,9 @@ virEventGLibHandleRemove(int watch) data, watch, data->fd); if (data->source != NULL) { + g_source_destroy(data->source); vir_g_source_unref(data->source, NULL); - g_clear_pointer(&data->source, g_source_destroy); + data->source = NULL; data->events = 0; } @@ -417,8 +419,9 @@ virEventGLibTimeoutUpdate(int timer, if (data->source == NULL) goto cleanup; + g_source_destroy(data->source); vir_g_source_unref(data->source, NULL); - g_clear_pointer(&data->source, g_source_destroy); + data->source = NULL; } cleanup: @@ -465,8 +468,9 @@ virEventGLibTimeoutRemove(int timer) data, timer); if (data->source != NULL) { + g_source_destroy(data->source); vir_g_source_unref(data->source, NULL); - g_clear_pointer(&data->source, g_source_destroy); + data->source = NULL; } /* since the actual timeout deletion is done asynchronously, a timeoutUpdate call may