mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-31 09:43:45 -04:00
[mdns] Fix missing check of the value-result from getsockopt(SO_ERROR)
The connection test would not catch "No route to host", as this is returned through the value-result buffer. This fix might partially solve issue #498.
This commit is contained in:
parent
93730281f4
commit
b3fc87170e
@ -484,6 +484,7 @@ connection_test(int family, const char *address, const char *address_log, int po
|
|||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
struct timeval timeout = { MDNS_CONNECT_TEST_TIMEOUT, 0 };
|
struct timeval timeout = { MDNS_CONNECT_TEST_TIMEOUT, 0 };
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
|
int error;
|
||||||
int retval;
|
int retval;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -529,15 +530,23 @@ connection_test(int family, const char *address, const char *address_log, int po
|
|||||||
goto out_close_socket;
|
goto out_close_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = sizeof(retval);
|
len = sizeof(error);
|
||||||
ret = getsockopt(sock, SOL_SOCKET, SO_ERROR, &retval, &len);
|
ret = getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_DBG, L_MDNS, "Connection test to %s:%d failed with getsockopt error: %s\n", address_log, port, strerror(errno));
|
DPRINTF(E_DBG, L_MDNS, "Connection test to %s:%d failed with getsockopt error: %s\n", address_log, port, strerror(errno));
|
||||||
goto out_close_socket;
|
goto out_close_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_MDNS, "Connection test to %s:%d completed successfully (return value %d)\n", address_log, port, retval);
|
if (error)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_MDNS, "Connection test to %s:%d failed with getsockopt return: %s\n", address_log, port, strerror(error));
|
||||||
|
goto out_close_socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_MDNS, "Connection test to %s:%d completed successfully\n", address_log, port);
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
out_close_socket:
|
out_close_socket:
|
||||||
close(sock);
|
close(sock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user