diff options
author | Kevin Wolf <kwolf@redhat.com> | 2009-12-02 12:24:42 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 11:45:50 -0600 |
commit | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 (patch) | |
tree | 98d560a0de229f27a66f637cfcadbb1672e68cc3 /net | |
parent | 12c09b8ce22d74f78ff50f95676cbe4f501752ae (diff) | |
download | hqemu-40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4.zip hqemu-40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4.tar.gz |
Don't leak file descriptors
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
descriptors that don't need to be passed to children to stop this misbehaviour.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/socket.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/socket.c b/net/socket.c index 7331d87..5533737 100644 --- a/net/socket.c +++ b/net/socket.c @@ -161,7 +161,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr) return -1; } - fd = socket(PF_INET, SOCK_DGRAM, 0); + fd = qemu_socket(PF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("socket(PF_INET, SOCK_DGRAM)"); return -1; @@ -355,7 +355,7 @@ static void net_socket_accept(void *opaque) for(;;) { len = sizeof(saddr); - fd = accept(s->fd, (struct sockaddr *)&saddr, &len); + fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len); if (fd < 0 && errno != EINTR) { return; } else if (fd >= 0) { @@ -386,7 +386,7 @@ static int net_socket_listen_init(VLANState *vlan, s = qemu_mallocz(sizeof(NetSocketListenState)); - fd = socket(PF_INET, SOCK_STREAM, 0); + fd = qemu_socket(PF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); return -1; @@ -427,7 +427,7 @@ static int net_socket_connect_init(VLANState *vlan, if (parse_host_port(&saddr, host_str) < 0) return -1; - fd = socket(PF_INET, SOCK_STREAM, 0); + fd = qemu_socket(PF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); return -1; |