From: Huawei Xie <huawei.xie@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] test whether file descriptor is valid before close it
Date: Fri, 6 Mar 2015 19:05:43 +0800 [thread overview]
Message-ID: <1425639943-27157-1-git-send-email-huawei.xie@intel.com> (raw)
In-Reply-To: <1425638358-26523-1-git-send-email-huawei.xie@intel.com>
This avoids closing -1 in our case.
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
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);
}
--
1.8.1.4
next prev parent reply other threads:[~2015-03-06 11:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 10:39 [dpdk-dev] [PATCH] lib/librte_vhost: exchange kickfd and callfd to avoid confusion Huawei Xie
2015-03-06 11:05 ` Huawei Xie [this message]
2015-03-09 1:32 ` [dpdk-dev] [PATCH] test whether file descriptor is valid before close it Ouyang, Changchun
2015-03-09 8:34 ` Thomas Monjalon
2015-03-09 2:23 ` Tetsuya Mukawa
2015-03-09 1:28 ` [dpdk-dev] [PATCH] lib/librte_vhost: exchange kickfd and callfd to avoid confusion Ouyang, Changchun
2015-03-09 8:33 ` Thomas Monjalon
2015-03-09 2:23 ` Tetsuya Mukawa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425639943-27157-1-git-send-email-huawei.xie@intel.com \
--to=huawei.xie@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).