diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2015-10-15 16:45:59 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2015-10-20 10:20:23 +0200 |
commit | c1e72c1be177544e5a718303dcb88412568f46d9 (patch) | |
tree | b53ec04c668dc6308a53225a51f16692ac49c1f3 | |
parent | aff6c79ae080db286e4cb853cdfa02f2da0d0398 (diff) |
Stop polling after reconnecting to libvirtd
When the connection to libvirtd is lost, virt-viewer starts polling for
libvirtd to come back. The polling mechanism is also used when
connecting to very old libvirtd which don't support
virConnectDomainEventDeregisterAny().
Currently, once we could reconnect to libvirtd, virt-viewer will keep
polling, thus behaving as if the libvirtd connection does not support
virConnectDomainEventDeregisterAny(). This commit makes sure we stop
polling once the new libvirtd connection is established.
This has the side-effect of preventing
https://bugzilla.redhat.com/show_bug.cgi?id=1271519 from occurring with
recent libvirt as it's caused by some race occurring when using the
polling code.
-rw-r--r-- | src/virt-viewer.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/virt-viewer.c b/src/virt-viewer.c index 851c83d..ca264c8 100644 --- a/src/virt-viewer.c +++ b/src/virt-viewer.c @@ -151,6 +151,20 @@ virt_viewer_start_reconnect_poll(VirtViewer *self) } static void +virt_viewer_stop_reconnect_poll(VirtViewer *self) +{ + VirtViewerPrivate *priv = self->priv; + + g_debug("reconnect_poll: %d", priv->reconnect_poll); + + if (priv->reconnect_poll == 0) + return; + + g_source_remove(priv->reconnect_poll); + priv->reconnect_poll = 0; +} + +static void virt_viewer_deactivated(VirtViewerApp *app, gboolean connect_error) { VirtViewer *self = VIRT_VIEWER(app); @@ -951,6 +965,10 @@ virt_viewer_connect(VirtViewerApp *app, GError **err) !virt_viewer_app_is_active(app)) { g_debug("No domain events, falling back to polling"); virt_viewer_start_reconnect_poll(self); + } else { + /* we may be polling if we lost the libvirt connection and are trying + * to reconnect */ + virt_viewer_stop_reconnect_poll(self); } if (virConnectRegisterCloseCallback(priv->conn, |