summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Meerwald-Stadler <pmeerw@pmeerw.net>2017-02-22 15:02:43 +0100
committerPeter Meerwald-Stadler <pmeerw@pmeerw.net>2017-03-06 08:22:33 +0100
commitdf9cda67d2041adad7a43a48435f473eb1143337 (patch)
tree623a76a1a6ac151cb8e8f808d1eefa51c28be341 /src/modules
parentad9c8603b0b100e00b52224d83ed4f86fe12b8dd (diff)
raop: Fix loop searching for port number
do...while not reachable, loop should try different ports in case EADDRINUSE is returned Coverity ID: #1398161 Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/raop/raop-client.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 94342d24..e39663db 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -799,13 +799,16 @@ static int open_bind_udp_socket(pa_raop_client *c, uint16_t *actual_port) {
}
do {
- *sa_port = htons(port);
+ int ret;
- if (bind(fd, sa, salen) < 0 && errno != EADDRINUSE) {
- pa_log("bind_socket() failed: %s", pa_cstrerror(errno));
+ *sa_port = htons(port);
+ ret = bind(fd, sa, salen);
+ if (!ret)
+ break;
+ if (ret < 0 && errno != EADDRINUSE) {
+ pa_log("bind() failed: %s", pa_cstrerror(errno));
goto fail;
}
- break;
} while (++port > 0);
pa_log_debug("Socket bound to port %d (SOCK_DGRAM)", port);