From patchwork Tue Jan 12 01:22:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 59589 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2451576lbb; Mon, 11 Jan 2016 17:25:51 -0800 (PST) X-Received: by 10.195.13.129 with SMTP id ey1mr95757344wjd.132.1452561951098; Mon, 11 Jan 2016 17:25:51 -0800 (PST) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id o11si55749400wjw.191.2016.01.11.17.25.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Jan 2016 17:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0C1Mhe6032440; Mon, 11 Jan 2016 20:22:44 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0C1Mfpx022120 for ; Mon, 11 Jan 2016 20:22:41 -0500 Received: from colepc.redhat.com (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0C1McU2016771; Mon, 11 Jan 2016 20:22:41 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Mon, 11 Jan 2016 20:22:32 -0500 Message-Id: <3d5ffbb7ad8575a00e25372d18d2398c16a8d98f.1452561712.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] rpc: socket: Minor cleanups X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com - Add some debugging - Make the loop dependent only on retries - Make it explicit that connect(2) success exits the loop - Invert the error checking logic --- src/rpc/virnetsocket.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 4f67c8f..80c21c1 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -620,6 +620,9 @@ int virNetSocketNewConnectUNIX(const char *path, char *rundir = NULL; int ret = -1; + VIR_DEBUG("path=%s spawnDaemon=%d binary=%s", path, spawnDaemon, + NULLSTR(binary)); + memset(&localAddr, 0, sizeof(localAddr)); memset(&remoteAddr, 0, sizeof(remoteAddr)); @@ -680,10 +683,15 @@ int virNetSocketNewConnectUNIX(const char *path, if (remoteAddr.data.un.sun_path[0] == '@') remoteAddr.data.un.sun_path[0] = '\0'; - while (retries && - connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) { - if (!(spawnDaemon && (errno == ENOENT || - errno == ECONNREFUSED))) { + while (retries) { + if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) == 0) { + VIR_DEBUG("connect() succeeded"); + break; + } + VIR_DEBUG("connect() failed, errno=%d", errno); + + if (!spawnDaemon || + (errno != ENOENT && errno != ECONNREFUSED)) { virReportSystemError(errno, _("Failed to connect socket to '%s'"), path); goto cleanup;