From patchwork Fri Sep 8 17:37:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Carpenter X-Patchwork-Id: 811733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=cypherpath.com header.i=@cypherpath.com header.b="jn410Qwz"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpl9j582bz9sBW for ; Sat, 9 Sep 2017 03:46:17 +1000 (AEST) Received: from localhost ([::1]:46710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqNM7-0006W9-Op for incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 13:46:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqNFQ-0000KJ-6R for qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqNFM-0008Hn-4g for qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:20 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:35051) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqNFL-0008Gr-UQ for qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:16 -0400 Received: by mail-pg0-x235.google.com with SMTP id 188so5918520pgb.2 for ; Fri, 08 Sep 2017 10:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cypherpath.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7v8W86ncP3U13C6xTc1W8Y2BQWzG/+kj5N+vW6FffrM=; b=jn410Qwzvh1lvaZZr4FZgpjMjoLXG9P+1CVF3Ex/0zTjGu5A0HZonVwe9tc20D4Qrm C8t+v7YOfOiL7pkMWi4p4ueJqYAA/usX4bePChCkuCmnhGPYviiqvD9jPPcs57H9eTwO I00HoEPjk6U8zZb4bpNgJj3Tq1s01rHmHBJkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=7v8W86ncP3U13C6xTc1W8Y2BQWzG/+kj5N+vW6FffrM=; b=uj0p5rApQC7ELNhkRjF2MbpQp6QcE9tPIcWwk3rapoIy852XEe4OJVcjw9YYSV/y4L uNOJGMrhdGPyvlGX0OHzkpEb2JMLWXR6/UvXtCLdcT4iGE6FtghE9GlmAi4SXLqnzmfN N8jHtUw6x3dBPar/jF6xJJRVLUKe75BakZB4QlsmskfhcUxw1ofFkI0QmDhqL0RP1MEa rBo5gd552F3txZDGvYL/wXwbtVE5u2PcwD0DzfDBX8nT/llC38iO3J6SUT9PyuFg+hUC lxpbMtexbBZPUmZ/sL+UhabW/vnvwXu2dtP09tKfvW8aNfln2RPL0GYGozkdUOGHddmd 1UeQ== X-Gm-Message-State: AHPjjUg7OqWhNH/ueL/9pqLUpEprv6eTbQicyoQ7NqbIw7jeOlRKyBWB vNjlT02vO3ha33gcjEAxnaMSGbBniJmE1PHVI3ITtntsHXAkRxMdMwL962U2nAKVxj+dRFC/CKw DqMTU MIME-Version: 1.0 X-Google-Smtp-Source: ADKCNb4JL0M+ncvGdZfNNc8hvZGn4Z/nnSXkHyx9C2O2OVsQJ1Sj3I4t51w179Wlrv79Ite7q/t/CA== X-Received: by 10.84.217.91 with SMTP id e27mr4091568plj.99.1504892354820; Fri, 08 Sep 2017 10:39:14 -0700 (PDT) Received: from servo.cypherpath.com (68-113-0-218.static.knwc.wa.charter.com. [68.113.0.218]) by smtp.gmail.com with ESMTPSA id c30sm4556833pgn.33.2017.09.08.10.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Sep 2017 10:39:14 -0700 (PDT) From: Brandon Carpenter To: qemu-devel@nongnu.org Date: Fri, 8 Sep 2017 10:37:56 -0700 Message-Id: <20170908173801.15205-2-brandon.carpenter@cypherpath.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170908173801.15205-1-brandon.carpenter@cypherpath.com> References: <20170908173801.15205-1-brandon.carpenter@cypherpath.com> In-Reply-To: <20170724184217.21381-1-brandon.carpenter@cypherpath.com> References: <20170724184217.21381-1-brandon.carpenter@cypherpath.com> <20170724181544.20292-1-brandon.carpenter@cypherpath.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::235 Subject: [Qemu-devel] [PATCH v2 1/6] io: Always remove an old channel watch before adding a new one X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: brandon.carpenter@cypherpath.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Also set saved handle to zero when removing without adding a new watch. Signed-off-by: Brandon Carpenter Reviewed-by: Paolo Bonzini Reviewed-by: Daniel P. Berrange --- ui/vnc-auth-vencrypt.c | 3 +++ ui/vnc-ws.c | 6 ++++++ ui/vnc.c | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c index ffaab57550..c3eece4fa7 100644 --- a/ui/vnc-auth-vencrypt.c +++ b/ui/vnc-auth-vencrypt.c @@ -77,6 +77,9 @@ static void vnc_tls_handshake_done(QIOTask *task, vnc_client_error(vs); error_free(err); } else { + if (vs->ioc_tag) { + g_source_remove(vs->ioc_tag); + } vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN | G_IO_OUT, vnc_client_io, vs, NULL); start_auth_vencrypt_subauth(vs); diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index f530cd5474..eaf309553c 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -36,6 +36,9 @@ static void vncws_tls_handshake_done(QIOTask *task, error_free(err); } else { VNC_DEBUG("TLS handshake complete, starting websocket handshake\n"); + if (vs->ioc_tag) { + g_source_remove(vs->ioc_tag); + } vs->ioc_tag = qio_channel_add_watch( QIO_CHANNEL(vs->ioc), G_IO_IN, vncws_handshake_io, vs, NULL); } @@ -97,6 +100,9 @@ static void vncws_handshake_done(QIOTask *task, } else { VNC_DEBUG("Websock handshake complete, starting VNC protocol\n"); vnc_start_protocol(vs); + if (vs->ioc_tag) { + g_source_remove(vs->ioc_tag); + } vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vnc_client_io, vs, NULL); } diff --git a/ui/vnc.c b/ui/vnc.c index 0b5dbc62e4..62f7a3f30a 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1121,6 +1121,7 @@ static void vnc_disconnect_start(VncState *vs) vnc_set_share_mode(vs, VNC_SHARE_MODE_DISCONNECTED); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); + vs->ioc_tag = 0; } qio_channel_close(vs->ioc, NULL); vs->disconnecting = TRUE; @@ -2931,6 +2932,9 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, VNC_DEBUG("New client on socket %p\n", vs->sioc); update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qio_channel_set_blocking(vs->ioc, false, NULL); + if (vs->ioc_tag) { + g_source_remove(vs->ioc_tag); + } if (websocket) { vs->websocket = 1; if (vd->tlscreds) {