From nobody Fri Dec 19 14:28:32 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 1744045071209175.3395204168529; Mon, 7 Apr 2025 09:57:51 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7093216F7; Mon, 7 Apr 2025 12:57:50 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6AA2A168D; Mon, 7 Apr 2025 12:57:34 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2A007166B; Mon, 7 Apr 2025 12:57:31 -0400 (EDT) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 45D0A164D for ; Mon, 7 Apr 2025 12:57:29 -0400 (EDT) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7376dd56eccso5011322b3a.0 for ; Mon, 07 Apr 2025 09:57:29 -0700 (PDT) Received: from Hyman-Dev-Euler.zelin.local (awork062012.netvigator.com. [203.198.28.12]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-af9bc2da718sm7626243a12.2.2025.04.07.09.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 09:57:27 -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=1744045048; x=1744649848; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=l9g5BPFWwV8yAVIld1T43ogAiiL52y2/SWATV8QM/I4=; b=RZ81zSAwyPfR9Qt6jctLj2qok/IeU2M8G2V/hweETySdBtnlMV2IWKaOr8Cd0L4Bl8 7EZvgxIuZA3K5ceODV7Owl/812ylLyVmnNHm0Wg/EqI7sjhT2n635eH+aqvoULJuP/yk /fTKd6xNz6gToYDmr81GzK9JCtwFv2CSEKAVXH0qgxr7bSgekl5pb2xywAZ9zgKNbxAA Jk35gWaO0USbPFttwSokAHcfRxIBg58ajz1qwLgR/cI463RuEQe0NpoHEo0aTyTu3l7m ByUD9qGUVnyslxl+mgzaMc6RJ+Qt1BfRsOu5F8kZC8EPrXKM8IkGJv+2PJr0vjMd+rlJ 3nUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744045048; x=1744649848; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l9g5BPFWwV8yAVIld1T43ogAiiL52y2/SWATV8QM/I4=; b=QZGbhlIO+zvsnRFFJioPVyWcT4k21enWs+l8K7/WRHPdm+49ve0GlmJR4cGORSaUTm YIWxXkdW2YiH6GC27ZDOOPIOEgpsiGfX2F2CKe/izwUYDovhXHOc1zNRmB9aLHaitjlf y3t9AL1o2aM0zDpF4YHLbKSpmiMrsWcPAT6hHourOgfPLhylg1D+7FVFELJdCooJc/mK Xgsxed5JEQexc7YrAXhEYHVD2I6pHnj1PGSZ4aSKvP2bGYajlwwvRoyXB0HIkWz9Jkpd weXKrCrfPWHel9r/+Rx7vWF91X1M1CtYpvQykprTaG50Rcq6a+GajW/dZO80teMHMOhC mF7w== X-Gm-Message-State: AOJu0Yy81mFfxdNx+z0CQHXrvrq6WZsM3XhQhZFg2piHVURoQsl0iKLQ i4OHdfyK59nQNn4nWaP+Nf2IdUYhkYx22WaqdNI2inhlJJi2WQHAZ6fj37pFudnhtzFGufaylRl KRvJkAqxd X-Gm-Gg: ASbGncuvWIngDpZAi5CKKi8YYhltWsLQ09mCedQ6ss5QFyqwhUsmMSFaHRK+1EBO8GI JBHwPF8RupbdrHUrX2BFgd5EW5JzupU3WzXlc+QFX4MDT9khSE6s02LJdMcttIJSrdFLr5xul8w nsL5A1Nqd1adr4RInUBp9eXipTi4R9QsBFNvaZPR2Lmqs+Rogxsp7YYKMom6ITpfuJ2+VxQgJ74 QZtzJjD8zMI6fkzgkUjQWlLAlbw3RMvdhuFRKEuvpfcOAaYPlZXgVvyrzZtlFYTxFy/oqR02534 M5gmJR1y7ptiBbPl4EHQrqgXF0futrRP9Y03Nxi0sGDmE5DqADD6S9284/hz/+5harCqP0soVj+ hwBDFFyxak8b73rDzrGFST5myixBfXaDJSy8N5rfDPXa3anWVW3fImr+giMFj X-Google-Smtp-Source: AGHT+IFEUHhzo2dp9aIHuP+FizMYoj4BxAizjb6FuzSV3Cnf91J/wD0flCTErR+fj4kuzaKVsHnglg== X-Received: by 2002:a05:6a20:6f96:b0:1f5:8eb1:d5d2 with SMTP id adf61e73a8af0-20107ef74f7mr18081577637.13.1744045048012; Mon, 07 Apr 2025 09:57:28 -0700 (PDT) From: yong.huang@smartx.com To: devel@lists.libvirt.org Subject: [PATCH] rpc: Re-read the data if EAGAIN or EINTR were captured Date: Tue, 8 Apr 2025 00:55:04 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4FGWLXPHDCB6P3TNLECJYFSE62HO7UCS X-Message-ID-Hash: 4FGWLXPHDCB6P3TNLECJYFSE62HO7UCS 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: 1744045074238019000 Content-Type: text/plain; charset="utf-8" From: Hyman Huang If EAGAIN or EINTR are returned from the gnutls_record_recv, GNU TLS suggests calling the gnutls_record_recv once again to get the data. Refer to the following link to see details: https://www.gnutls.org/manual/html_node/Data-transfer-and-termination.html To follow this guidance, add the re-read logic in the virNetClientSetTLSSession function. This prevent the upper application, when calling the virConnectOpenAuth API, from receiving the follwoing error message: Unable to read TLS confirmation: Resource temporarily unavailable --- src/rpc/virnetclient.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 92933220e2..69b8cac481 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1003,7 +1003,16 @@ int virNetClientSetTLSSession(virNetClient *client, ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); #endif /* !WIN32 */ =20 + reread: len =3D virNetTLSSessionRead(client->tls, buf, 1); + /* + * GNU TLS advises calling the function again to obtain the data if EA= GAIN is returned. + * See reference: https://www.gnutls.org/manual/html_node/Data-transfe= r-and-termination.html + * */ + if (len < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) { + VIR_WARN("Try reading data from the TLS session again"); + goto reread; + } if (len < 0 && errno !=3D ENOMSG) { virReportSystemError(errno, "%s", _("Unable to read TLS confirmation")); --=20 2.27.0