[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 1/6] tap: Avoid extra iterations while closing file f
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 1/6] tap: Avoid extra iterations while closing file fd |
Date: |
Fri, 25 Apr 2014 16:09:35 +0200 |
From: Pankaj Gupta <address@hidden>
Avoid iterations for fd 0, 1 & 2 when we are closing file fds in child process.
Signed-off-by: Pankaj Gupta <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
net/tap.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/net/tap.c b/net/tap.c
index 8847ce1..fc1b865 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -367,11 +367,8 @@ static int launch_script(const char *setup_script, const
char *ifname, int fd)
if (pid == 0) {
int open_max = sysconf(_SC_OPEN_MAX), i;
- for (i = 0; i < open_max; i++) {
- if (i != STDIN_FILENO &&
- i != STDOUT_FILENO &&
- i != STDERR_FILENO &&
- i != fd) {
+ for (i = 3; i < open_max; i++) {
+ if (i != fd) {
close(i);
}
}
@@ -452,11 +449,8 @@ static int net_bridge_run_helper(const char *helper, const
char *bridge)
char br_buf[6+IFNAMSIZ] = {0};
char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15];
- for (i = 0; i < open_max; i++) {
- if (i != STDIN_FILENO &&
- i != STDOUT_FILENO &&
- i != STDERR_FILENO &&
- i != sv[1]) {
+ for (i = 3; i < open_max; i++) {
+ if (i != sv[1]) {
close(i);
}
}
--
1.9.0
- [Qemu-devel] [PULL 0/6] Net pull request, Stefan Hajnoczi, 2014/04/25
- [Qemu-devel] [PULL 1/6] tap: Avoid extra iterations while closing file fd,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 2/6] pcnet: remove duplicate assignment, Stefan Hajnoczi, 2014/04/25
- [Qemu-devel] [PULL 6/6] net: Don't use error_is_set() to suppress additional errors, Stefan Hajnoczi, 2014/04/25
- [Qemu-devel] [PULL 4/6] net: xilinx_axienet.c: Add phy soft reset bit clearing, Stefan Hajnoczi, 2014/04/25
- [Qemu-devel] [PULL 3/6] net/net.c: Remove unnecessary semicolon, Stefan Hajnoczi, 2014/04/25
- [Qemu-devel] [PULL 5/6] net: Make qmp_query_rx_filter() with name argument more obvious, Stefan Hajnoczi, 2014/04/25
- Re: [Qemu-devel] [PULL 0/6] Net pull request, Peter Maydell, 2014/04/28