From patchwork Thu Aug 16 15:32:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Kotov X-Patchwork-Id: 10567859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 981A5913 for ; Thu, 16 Aug 2018 16:45:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 877E52B53C for ; Thu, 16 Aug 2018 16:45:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C1852B544; Thu, 16 Aug 2018 16:45:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3107E2B53C for ; Thu, 16 Aug 2018 16:45:29 +0000 (UTC) Received: from localhost ([::1]:56963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqLOq-0006be-G9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Aug 2018 12:45:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqKGg-000451-TM for qemu-devel@nongnu.org; Thu, 16 Aug 2018 11:32:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqKGg-0002oI-1G for qemu-devel@nongnu.org; Thu, 16 Aug 2018 11:32:58 -0400 Received: from forwardcorp1o.cmail.yandex.net ([2a02:6b8:0:1a72::290]:46256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqKGf-0002n4-NA for qemu-devel@nongnu.org; Thu, 16 Aug 2018 11:32:57 -0400 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id 986AD216C8; Thu, 16 Aug 2018 18:32:55 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id TJcmgZIVVP-WtZeNgXV; Thu, 16 Aug 2018 18:32:55 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534433575; bh=0QIzaDdah3tsa+JEcxogjQ/e94+YiuZgK7heIv2c1/4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=R1aOlx81QQ356mBuKo38tU5g5Sqqsh/4DQrn4HvUPdrQUEbJpjDC8KXV20vtofN5C DkIU2xU73JMPtTW+s7HKu1pkiYBX+pjQ8yTx4NaOzaL65OjifKhX15XQewg+ALXCEq 5W36f1SPMrg24LbmEWV/5aSKRnczxgIsZmGQRskM= Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:e1bb:a1a7:a235:d6b4]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 7WDIxKFPmc-WtXuDL3t; Thu, 16 Aug 2018 18:32:55 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534433575; bh=0QIzaDdah3tsa+JEcxogjQ/e94+YiuZgK7heIv2c1/4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=R1aOlx81QQ356mBuKo38tU5g5Sqqsh/4DQrn4HvUPdrQUEbJpjDC8KXV20vtofN5C DkIU2xU73JMPtTW+s7HKu1pkiYBX+pjQ8yTx4NaOzaL65OjifKhX15XQewg+ALXCEq 5W36f1SPMrg24LbmEWV/5aSKRnczxgIsZmGQRskM= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 18:32:41 +0300 Message-Id: <1534433563-30865-2-git-send-email-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534433563-30865-1-git-send-email-yury-kotov@yandex-team.ru> References: <1534433563-30865-1-git-send-email-yury-kotov@yandex-team.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:6b8:0:1a72::290 Subject: [Qemu-devel] [PATCH 1/3] chardev: prevent extra connection attempt in tcp_chr_machine_done_hook 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: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Evgeny Yakovlev , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Usually chardev connects to specified address during the initialization. But if reconnect_time is specified then connection will be postponed until machine done event. Thus if reconnect is specified and some device forces connection during initialization, tcp_chr_machine_done_hook will do useless connection attempt. So add a check to prevent it. Signed-off-by: Yury Kotov Signed-off-by: Evgeny Yakovlev --- chardev/char-socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index efbad6e..116dcc4 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1165,7 +1165,10 @@ static int tcp_chr_machine_done_hook(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); - if (s->reconnect_time) { + /* It's possible that connection was established during the device + * initialization. So check if the socket is already connected to + * prevent extra connection attempt. */ + if (!s->connected && s->reconnect_time) { tcp_chr_connect_async(chr); }