[Spice-devel] [PATCH spice-gtk 1/2] Clean-up idle handler when leaving the open_host_idle()
Christophe Fergeau
cfergeau at redhat.com
Mon Dec 24 08:31:10 PST 2012
On Sun, Dec 23, 2012 at 10:35:33PM +0100, Marc-André Lureau wrote:
> An explicit yield back to the channel coroutine when the idle function
> is still pending will leave it in the background, referencing objects
> that may no longer exist. Make sure we remove it when
> channel_open_host() is resumed.
I've seen warnings that seemed related to this, so this patch is probably
useful.
> ---
> gtk/spice-session.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index b18d67b..f1d6250 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -1713,18 +1713,16 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
> open_host.channel = channel;
> open_host.port = atoi(use_tls ? s->tls_port : s->port);
> open_host.client = g_socket_client_new();
> - g_idle_add(open_host_idle_cb, &open_host);
>
> + guint id = g_idle_add(open_host_idle_cb, &open_host);
> /* switch to main loop and wait for connection */
> coroutine_yield(NULL);
> - if (open_host.error != NULL) {
> - g_return_val_if_fail(open_host.socket == NULL, NULL);
> + g_source_remove (id);
>
> + if (open_host.error != NULL) {
> g_warning("%s", open_host.error->message);
> g_clear_error(&open_host.error);
> - } else {
> - g_return_val_if_fail(open_host.socket != NULL, NULL);
> -
> + } else if (open_host.socket != NULL) {
> g_socket_set_blocking(open_host.socket, FALSE);
> g_socket_set_keepalive(open_host.socket, TRUE);
> }
Should we have an else { g_warn_if_reached(); } there?
ACK whether you change it or not.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20121224/64f8dc19/attachment.pgp>
More information about the Spice-devel
mailing list