From nobody Mon Sep 8 21:39:54 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 1747192505668750.9769703040068; Tue, 13 May 2025 20:15:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0DCCEC99; Tue, 13 May 2025 23:15:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2CD4DCBC; Tue, 13 May 2025 23:14:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8288EC7A; Tue, 13 May 2025 23:14:27 -0400 (EDT) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 D776CC7F for ; Tue, 13 May 2025 23:14:26 -0400 (EDT) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-879d2e419b9so5796178a12.2 for ; Tue, 13 May 2025 20:14:26 -0700 (PDT) Received: from Hyman-Dev-Euler.zelin.local ([45.8.186.102]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc8271a72sm89492115ad.112.2025.05.13.20.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 May 2025 20:14:25 -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_H2,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=1747192465; x=1747797265; 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=Bdi6u1dAtav/mgsQGEe2TyZTqvga2xsDjmntbjTpX9A=; b=uzgK/s4YmPsXL2N4PlNNwPpVRzqEcA/6vdtOnlZxP+bqYuZ/Aom27nMTToogFK2SOG VQaZ+jRzkPgMllQ+5LX+QziOUDiMh/e0NKZr8NBeoH4m5MX49DY3SCh3intFEn6Pd0Xj NBt3h0oPpdhJJK2qffYowB07pBfNM9zV0hVDpKTKyve4rTjgSgIv/gKOD649NMDJpwN9 QwqV3kRyTl8cKrSF0SICqkCH0cEX/yYG5jZbMsTc+8uNEEiirC1582HF6tmO/jmu5xv0 3yZNbI3EYzkj1l4RvCdBXRu2Q+WSwRt7ELRK6HbZjbUnRAKETki6EQRDdjKVDBenzcXS 0Mlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747192465; x=1747797265; 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=Bdi6u1dAtav/mgsQGEe2TyZTqvga2xsDjmntbjTpX9A=; b=fj4ab8MUwRV5a8B80oG0abeTI0qw96lKmnoT1hg4gseds2E7wo4mbSAGUeEXPhpzf8 MPkH2Ev9Z/rfHfnsEqTI9PtIiFPov55HTSGWQ2kUoI7j7QOAtMhfem9RW1O7dO5HQ6ep /MzOlMc3IzNRxptW12ciW/f+cSHhRtaFXK2BnwEGfT+df0ncAlBBuYMLwSBR4FvDwyHt XHSjqms59fTnVDyxvuivpRlTZFjEwEzoBhzKr9/By+vAxo1V/BQdsFgAZmumU6SFlsDk GLcjamNy2iKfJZ1J86Qd5X7RQ/bWSszkwDb4/BCZOOPDqleHG3reD5igXRIltNQYy3XH cglA== X-Gm-Message-State: AOJu0YwjulJdmuxiOtULKWPa53snwWNnGysDu8iuLX7QzE5Yzahfg2uB tzAXekeeyTPcHY0O8FhGwLWCeqs0D10Sq6b0YmOHzzrsRMNMCfYQ7QOQmaTQ44pfk6m81S4+gwK DWbc= X-Gm-Gg: ASbGncva+pIXXzmR1vBIr+MGPl+9+uDtmsjMKnOEmwVJiJHLEkO6TxZqBcOciTwg4sH rZFeXPJ8aI+Rp0g+Fk3Q3iEGNA2Vs+ptcvNqQoTn+qb0V+AopMCEIOXzL9BIEJjMEmI02Fu4b18 PJcqgzS2eZ4/3/dt/xnl2RYissWckorRbc+2B/hxyR/AexeNQcFaNYITpmIgoBXi1IxOU4J1z4K fqWyOeriWVY8EcMbqfxL4wZ0UU5LzleduCGcql5L1kiLm3xDRSovrVboWtI8YXgnufzZQoFxsmc qUnoKzaG11EmaaXnQ+FDd4RKFH+CXUbupVfjHOJDzdB++fWa+Kzma54AKxiSa0wttIWkWSd79A= = X-Google-Smtp-Source: AGHT+IFq0dyjFmKwdzOwUYz/tvmXXXAtpBcw0j4zF2NNQXfSQ9VPlhBGX9R1i6/QUVMmXsG2w1PS4A== X-Received: by 2002:a17:902:d2cf:b0:223:5e56:a1ce with SMTP id d9443c01a7336-23198148cf8mr28215045ad.32.1747192465356; Tue, 13 May 2025 20:14:25 -0700 (PDT) From: yong.huang@smartx.com To: devel@lists.libvirt.org Subject: [PATCH v2 1/1] rpc: Add the {repoll,retry} logic in virNetClientSetTLSSession Date: Wed, 14 May 2025 11:14:11 +0800 Message-Id: <0c6c9c1435e0c22863807c77e77245f21947b03e.1747191491.git.yong.huang@smartx.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YZOHYEDXXRDWHZFRMPQEPEZKIVULALM3 X-Message-ID-Hash: YZOHYEDXXRDWHZFRMPQEPEZKIVULALM3 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: Hyman Huang 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: 1747192507452019000 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..833ac0e9d3 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