From nobody Mon Sep 8 22:02:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=smartx.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1747193117670942.3615892366454; Tue, 13 May 2025 20:25:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 07357CBA; Tue, 13 May 2025 23:25:17 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 29D7511D9; Tue, 13 May 2025 23:24:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B6277C97; Tue, 13 May 2025 23:24:36 -0400 (EDT) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1F2B5C93 for ; Tue, 13 May 2025 23:24:36 -0400 (EDT) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-30ac55f595fso5797302a91.2 for ; Tue, 13 May 2025 20:24:36 -0700 (PDT) Received: from Hyman-Dev-Euler.zelin.local ([45.8.186.102]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30e334fb834sm413709a91.48.2025.05.13.20.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 May 2025 20:24:34 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1747193075; x=1747797875; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hdFFLNrXfP6LSg0GYLSYne1+22ufOqQ6Cs0OduBOCbs=; b=p6VeoWdLaTSPdOo6fq6H9AzkUsCf9kPnpZvIvQzlJ3/z/lgPVDk1LXh0bF5Tz6QQtg CTwwC/OgZ4P/odork4CFcMf8WNt1ji4dgUoPwcrjWKctLAWd6PYha9+EC1aYDvSjLlXw K5VrMNCZUsHRXlaXu86qnsrchl/jQsO6KYGeH1Qq3SNHYJR/m85gne/0c2vBIu95VYLe sgXyDagtE8RO1lHBYo5lvZasHjjKm3ydU78aZlpPvaMLuqviLBdrpFbQF5ZF68LmysZm 3jVxO7gUnqHtUj5V8SZOCESfsF6XtYLQ8bjburzCKpUVhZ77Qy5vW4xjQT/ncGYhYNkc vLNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747193075; x=1747797875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hdFFLNrXfP6LSg0GYLSYne1+22ufOqQ6Cs0OduBOCbs=; b=PzSHcCPuEXYDQHntOQZQQNEzEQDf5nYg1PIW/abuYVhehzAfYeTLHjcLejR5uiWXt/ NZ5CkKED8pfwuQf1VbCW7m/mbaI+aDkOLHW2L+/P5ckRGWxOllJSH0W9LDTnCxRKdJee yQZhIMIcev3Nb5WGu8vFrCLVELFpOGRtV+x0mTcI+J4QbOLotx3GELlYDu2GPR9JhQrA CBu/wDNDFSL44wwYALA817hPZBgr8Voj1pgbYd2gespATDHGlKMdGyaOH/n/97F5PdZr I5ZG/FXQxqM0XcBH7NfPs6o694+90luF3UJc+jfyZRrEVDb0BPaFzxqDC/gj2iVhuJ64 TIMg== X-Gm-Message-State: AOJu0Yw7oqDi7ZOeujjuz0pJYA3TtfrxLZk4NsCjTf86rx+Nnh6IN2YG cFQve5UiCiutRuDu99CFGGgj4hIDGtxFQNAoP0hrTf2LnyEqQ+qLupPHOLphfS2xKe6X3IGbTja LvsGomuAc X-Gm-Gg: ASbGncsPuDCiChhLA2GN7qwIICLbTDjua1WVQh9cI1WkxvEkJC8RP/xeeRRLMlzGMMj 7FNBdSj+NNstObh93HoeNnLjGQW9g9/ftIlLeplYfefgd7Xvh1eggDv8P0CI50sFG25IoEaQH+b palKEH+675sC8RX/EakOx4+6kiYE/+noFOoYBYpdMv7Au7UfB1T+TpL2Lx5mjqX4GDXTDAayCj9 NthF6L2l3hVEmY5UQf6NjFsSNWyoktNwoOSqVHz649AkniZDpu7OLHkI/sCDkIUk2+c5ddgUjY6 A4oC6/4vGFoVopLrTBvUirIZzezRmYw7EsqJLuh/nJ7BSYdwOdHYq7kI45gKz/yl2magASzGBXi dWT5F/xUO X-Google-Smtp-Source: AGHT+IF4Qs9SXkbtwbbylHWU+h5cnUVTEiy8+zqSeb2gcVV3r/E5+nQet/IWYG2QuN7GTIVHqqvccQ== X-Received: by 2002:a17:90b:380e:b0:2ff:5ed8:83d0 with SMTP id 98e67ed59e1d1-30e2e5c84cdmr3169107a91.16.1747193074820; Tue, 13 May 2025 20:24:34 -0700 (PDT) From: yong.huang@smartx.com To: devel@lists.libvirt.org Subject: [RESEND PATCH v2 1/1] rpc: Add the {repoll,retry} logic in virNetClientSetTLSSession Date: Wed, 14 May 2025 11:24:22 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QKDZ3P33MSD75NKZDWB2MP5WCOECI6CK X-Message-ID-Hash: QKDZ3P33MSD75NKZDWB2MP5WCOECI6CK X-MailFrom: yong.huang@smartx.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yong.huang@smartx.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1747193119408019000 Content-Type: text/plain; charset="utf-8" From: Hyman Huang As advised by the GNU TLS, the caller should attempt again if the gnutls_record_{recv,send} return EAGAIN or EINTR; check the following link to view the details: https://www.gnutls.org/manual/html_node/Data-transfer-and-termination.html virNetClientSetTLSSession failed to handle EINTR/EGAIN, though EGAIN seems like it ought to be unlikely given that the caller waited for G_IO_IN. Add the {repoll, retry} logic to handle EINTR/EGAIN that may happen theoretically. This may reduce the likelihood that the upper application receives the following error message utmostly when it calls the virConnectOpenAuth API: Unable to read TLS confirmation: Resource temporarily unavailable Note that in order to fully avoid the mentioned problem, the upper application should retry virConnectOpenAuth. --- src/rpc/virnetclient.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 92933220e2..ee729d5e62 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -987,6 +987,7 @@ int virNetClientSetTLSSession(virNetClient *client, * etc. If we make the grade, it will send us a '\1' byte. */ =20 + repoll: source =3D virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), G_IO_IN, client->eventCtx, @@ -1003,7 +1004,14 @@ int virNetClientSetTLSSession(virNetClient *client, ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); #endif /* !WIN32 */ =20 + retry: len =3D virNetTLSSessionRead(client->tls, buf, 1); + if (len < 0 && errno =3D=3D EINTR) { + goto retry; + } + if (len < 0 && errno =3D=3D EAGAIN) { + goto repoll; + } if (len < 0 && errno !=3D ENOMSG) { virReportSystemError(errno, "%s", _("Unable to read TLS confirmation")); --=20 2.27.0