summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-12-02 12:24:42 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-03 11:45:50 -0600
commit867f1ecc9722dac7b18ad6e4a2621b771bc99c8a (patch)
tree98d560a0de229f27a66f637cfcadbb1672e68cc3 /net
parentfebd445b8229b34676205aac4bee62d377ec3da0 (diff)
downloadqemu-867f1ecc9722dac7b18ad6e4a2621b771bc99c8a.tar.gz
qemu-867f1ecc9722dac7b18ad6e4a2621b771bc99c8a.tar.bz2
qemu-867f1ecc9722dac7b18ad6e4a2621b771bc99c8a.zip
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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/socket.c b/net/socket.c
index 7331d87c67..5533737e4b 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;