diff options
author | Knut Omang <knut.omang@oracle.com> | 2017-08-07 12:58:42 +0200 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2017-10-16 16:55:31 +0100 |
commit | 9cf961bba74d433db76a110917ac70aecc2ebcc4 (patch) | |
tree | 5931ee4bd06ad8bc14ce497609eeb06bcfb5859a /vl.c | |
parent | 39f80521df1e7f1252960d1ada2bd1a41d4d2cd3 (diff) |
sockets: Handle race condition between binds to the same port
If an offset of ports is specified to the inet_listen_saddr function(),
and two or more processes tries to bind from these ports at the same time,
occasionally more than one process may be able to bind to the same
port. The condition is detected by listen() but too late to avoid a failure.
This function is called by socket_listen() and used
by all socket listening code in QEMU, so all cases where any form of dynamic
port selection is used should be subject to this issue.
Add code to close and re-establish the socket when this
condition is observed, hiding the race condition from the user.
Also clean up some issues with error handling to allow more
accurate reporting of the cause of an error.
This has been developed and tested by means of the
test-listen unit test in the previous commit.
Enable the test for make check now that it passes.
Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Girish Moodalbail <girish.moodalbail@oracle.com>
Signed-off-by: Knut Omang <knut.omang@oracle.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'vl.c')
0 files changed, 0 insertions, 0 deletions