From nobody Mon Sep 8 21:39:52 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 1747271328673838.4257431991309; Wed, 14 May 2025 18:08:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B869211CD; Wed, 14 May 2025 21:08:47 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0DC4212DC; Wed, 14 May 2025 21:08:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A5A511D3; Wed, 14 May 2025 21:08:02 -0400 (EDT) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 8EF4C11CF for ; Wed, 14 May 2025 21:08:01 -0400 (EDT) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7398d65476eso342514b3a.1 for ; Wed, 14 May 2025 18:08:01 -0700 (PDT) Received: from Hyman-Dev-Euler.zelin.local ([154.64.226.176]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b2350ddb6e8sm9540797a12.57.2025.05.14.18.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 May 2025 18:08:00 -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=1747271280; x=1747876080; 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=P1gEQXwPYantpbCeivYX8uQphVjpegoe7L93IJspaEk=; b=tBsIH6dUBltyeOlmlJWOIjnCo6532oSrU/HdoIurPLdf1cHBJh8QpMo2/VFMpIaAWr OE8TUWc8EvbaqCw0NZJUkXri6xO29SH3oQZxJCjL3wgtFp6gIDmxjtVBBfQozYC5/RDt OitrZvpoNd6OfrOA1KQi5MFrR/O/khiv27soBV3y8Pz0DZvIeNI3hGXU3d+kPd2F8rF8 cqwoeGyod3q532hG/uLY0hPj9WknI0OTMFqakDpUdWwUMzJSgWUi78VWpz3Mh98WYQ/I gcg7i9SteEg77swkb2pnJ+hWIKDApVkQWZMlEGt2Tt97gCXAz+dT6Otrq/wkIAn7abyN DR5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747271280; x=1747876080; 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=P1gEQXwPYantpbCeivYX8uQphVjpegoe7L93IJspaEk=; b=xQETMoIRNa4UU/JBZM9SHrN0iPUOJSUwVLXFXGa9ls/JrgPfFqQnh5oOMUjwZFgQjy mjAEnHAyTCTuDyozzTfy6boyTEuI83oNss9Uf4MUbHfen7rBZGXXhOOleNWTlegIY6gi um7GcDGqneIo2XsV9Rjc/LUImBYHLmncuTSNzb64LXtrjLTlE72QUtNB21euBhQNhG1t DGqSLEFfiFVSXTSnfC/HvKZ4jmAVgL6aq/ozvcTHrHE33vz0Zz1iDnIaRimnKxKQgKbu hrWhA2kWGf68sgIgx9wg6yxNyLHKDFvT7VKVA/tFp4C669lTvgttwYZ/wx2E6O49Jeum SxBg== X-Gm-Message-State: AOJu0YxOJKmWvdL+ZwXRS5wAoTrtUIKWsNbErRwX16CuvdibaMpRJZAu stXT/niXgowqidw5uhwZdtEfzmgJYKobI35eveI94KsCaPl1T4Ca08jj+2cwbRrPgTV37trwyjh LR32Tn4oomw== X-Gm-Gg: ASbGncvPwdeCdhjgmf9AOjYJ3W5KqT5IRom1cJcYdLLfQ663XM0BDW8IboVNAq6pAIN 1bZrpwtp3UoI6ZoKm0aTntt3DCcFsPXRTyIz6oRr3DFuKDD56e1mpLpPQj0S4bYuy4BU4XiXLm0 gHH8hdgnFiDl4kYE/KMHYVZtxm6dMPy6bcBJ5DSFiKtw2IHghv7a8eWE8lz9oumbQsDOszQeTeT vEoVjXzKPoYhbzDvR1HFqYtUeLNEsD3BRCWU6yNnNemZ/NTas2OpKeq2QcNJa1u+ilcHLzU91nM Nf58un02scPafPFE5zo4Zedzdj7ZxHbOEUdx3DYEXym5bXmkAFNYH7YfAw+s7AkzqAmYQ04Dh2T 3FDntcNLr2vkp5jJcZ2Bag4pGu2WgIkFAhsaBZxQ2AA== X-Google-Smtp-Source: AGHT+IHMlatojILKR6hG2PK/n+FeTXCkvwBNfg5QqRtaqIuhSEz4Yv5MRdTHevv8/S/22ar2fFlFDQ== X-Received: by 2002:a05:6a21:398b:b0:1ee:c8a4:c329 with SMTP id adf61e73a8af0-2160d3fe664mr2265279637.0.1747271280447; Wed, 14 May 2025 18:08:00 -0700 (PDT) From: yong.huang@smartx.com To: devel@lists.libvirt.org Subject: [PATCH v3 1/1] rpc: Add the {repoll,retry} logic in virNetClientSetTLSSession Date: Thu, 15 May 2025 09:07:41 +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: P6UBNE5KDSVSJQ3YFF5N5YVSOKELJU5N X-Message-ID-Hash: P6UBNE5KDSVSJQ3YFF5N5YVSOKELJU5N 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: 1747271330222116600 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. Signed-off-by: Hyman Huang Reviewed-by: Daniel P. Berrang=C3=A9 --- 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