On 10/20/2017 09:12 AM, Daniel P. Berrange wrote: > If we iterate over the full port range without successfully binding+listening > on the socket, we'll try the next address, whereupon we overwrite the slisten > file descriptor variable without closing it. > > Rather than having two places where we open + close socket FDs on different > iterations of nested for loops, re-arrange the code to always open+close > within the same loop iteration. > > Signed-off-by: Daniel P. Berrange <berra...@redhat.com> > --- > util/qemu-sockets.c | 52 +++++++++++++++++++++++++++++----------------------- > 1 file changed, 29 insertions(+), 23 deletions(-) >
> + slisten = create_fast_reuse_socket(e); > + if (slisten < 0) { > + /* First time we expect we might fail to create the socket > + * eg if 'e' has AF_INET6 but ipv6 kmod is not loaded. > + * Later iterations should always succeeed if first iteration s/succeeed/succeed/ Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature