On Tue, Apr 08, 2025 at 01:25:02PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmar...@redhat.com>
> 
> To get a listening socket, we need to first create a socket, try binding
> it to a certain port, and lastly starting listening to it. Each of these
> operations can fail due to various reasons, one of them being that the
> requested address/port is already in use. In such case, the function
> tries the same process with a new port number.
> 
> This patch refactors the port number loop, so the success path is no
> longer buried inside the 'if' statements in the middle of the loop. Now,
> the success path is not nested and ends at the end of the iteration
> after successful socket creation, binding, and listening. In case any of
> the operations fails, it either continues to the next iteration (and the
> next port) or jumps out of the loop to handle the error and exits the
> function.
> 
> Signed-off-by: Juraj Marcin <jmar...@redhat.com>
> ---
>  util/qemu-sockets.c | 51 ++++++++++++++++++++++++---------------------
>  1 file changed, 27 insertions(+), 24 deletions(-)

Reviewed-by: Daniel P. Berrangé <berra...@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to