mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
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>
This commit is contained in:
parent
12c09b8ce2
commit
40ff6d7e8d
20 changed files with 178 additions and 34 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue