agent: report duplicated port in udp bsd sockets too
authorFabrice Bellet <fabrice@bellet.info>
Sat, 26 Sep 2020 15:02:12 +0000 (17:02 +0200)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Mon, 7 Dec 2020 21:52:55 +0000 (21:52 +0000)
commit7ec7f66d4eb52b5f018cf700fd41d18b5666543c
tree0265aa70516aaebeac5d0495a31762f2c8aca0c1
parentcadf5118284ea08ac7db020f741c0772d5d84941
agent: report duplicated port in udp bsd sockets too

This patch fixes cases, where the range is full, some ports fail with
HOST_CANDIDATE_CANT_CREATE_SOCKET, other fail with
HOST_CANDIDATE_DUPLICATE_PORT, the value of res we keep when leaving the
loop is randomly the one of the last iteration of the loop.

CANT_CREATE_SOCKET still happens when trying to create an udp bsd socket
with the same address and port than one of another component, so it is
also a case of duplicate port in fact.

To be homogeneous, we add a gerror for nice_udp_bsd_socket_new(), like
we did in nice_tcp_passive_socket_new(), and we can catch the same
G_IO_ERROR_ADDRESS_IN_USE there too, when failing to get free available
udp ports.

This patch is a complement to merge request !158
agent/agent.c
agent/discovery.c
socket/udp-bsd.c
socket/udp-bsd.h
tests/test-bsd.c
tests/test-drop-invalid.c
tests/test-socket-is-based-on.c