From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 95D905A9C for ; Mon, 9 Mar 2015 03:23:17 +0100 (CET) Received: by padfb1 with SMTP id fb1so59615004pad.7 for ; Sun, 08 Mar 2015 19:23:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=YUQl630LTOyyDcGMoe4orPUWQUK2KroMCeDRRFLvHzc=; b=DXixMb4q+NPSXKFJmeUCo0i5niGZxjTfukI82MPlhuHRH1/6KO17+v4AIUTxYkNPQ7 HLbpPe75wnCmj51p5e/1+xvt44uZdG1HIve5kbtSJI8J3qcJILyRCM7oeZn7KgilrUiz eNVpuJR2UM+At0oJnElTrCVaNkA0mU2dewJqLckzAUJOzWt40Iz/ibGAaz5rirtcDhLq krGhrlaIiX6IrPGNgn6UHaPgGhNANB7UKPyMxmdxy7Af8rU6jXYNfnfZmhUrQuDPfdFR Tb3KuIeq3vXle4Vx8IZy4AKbL1ZSt52s8vjDb8jB2rhRHIX3b8gvGKetYCi0QdCmsdOc qFNw== X-Gm-Message-State: ALoCoQmztFCZHaFhJy2yKEMt81qXB8YUsDgkpIZrVAvtWiFz5kudhFmAyG3jj1kiKzkafsDZU+MZ X-Received: by 10.66.132.6 with SMTP id oq6mr49164114pab.29.1425867796913; Sun, 08 Mar 2015 19:23:16 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id k2sm16244289pdm.64.2015.03.08.19.23.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Mar 2015 19:23:16 -0700 (PDT) Message-ID: <54FD0413.9070804@igel.co.jp> Date: Mon, 09 Mar 2015 11:23:15 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Huawei Xie , dev@dpdk.org References: <1425638358-26523-1-git-send-email-huawei.xie@intel.com> <1425639943-27157-1-git-send-email-huawei.xie@intel.com> In-Reply-To: <1425639943-27157-1-git-send-email-huawei.xie@intel.com> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] test whether file descriptor is valid before close it X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2015 02:23:17 -0000 On 2015/03/06 20:05, Huawei Xie wrote: > This avoids closing -1 in our case. > > Signed-off-by: Huawei Xie > --- > lib/librte_vhost/virtio-net.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c > index 6917fcf..4672e67 100644 > --- a/lib/librte_vhost/virtio-net.c > +++ b/lib/librte_vhost/virtio-net.c > @@ -185,13 +185,13 @@ cleanup_device(struct virtio_net *dev) > } > > /* Close any event notifiers opened by device. */ > - if (dev->virtqueue[VIRTIO_RXQ]->callfd) > + if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0) > close((int)dev->virtqueue[VIRTIO_RXQ]->callfd); > - if (dev->virtqueue[VIRTIO_RXQ]->kickfd) > + if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0) > close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd); > - if (dev->virtqueue[VIRTIO_TXQ]->callfd) > + if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0) > close((int)dev->virtqueue[VIRTIO_TXQ]->callfd); > - if (dev->virtqueue[VIRTIO_TXQ]->kickfd) > + if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0) > close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd); > } > Acked-by: Tetsuya Mukawa