ntp: improve check for PTP socket

Check for INVALID_SOCK_FD in case the PTP port is enabled, but opening
one of the PTP sockets failed.
This commit is contained in:
Miroslav Lichvar 2021-11-24 15:05:15 +01:00
parent 701b9415a5
commit d7a444593f

View file

@ -332,7 +332,8 @@ NIO_OpenServerSocket(NTP_Remote_Address *remote_addr)
static int
is_ptp_socket(int sock_fd)
{
return ptp_port > 0 && (sock_fd == ptp_sock_fd4 || sock_fd == ptp_sock_fd6);
return ptp_port > 0 && sock_fd != INVALID_SOCK_FD &&
(sock_fd == ptp_sock_fd4 || sock_fd == ptp_sock_fd6);
}
/* ================================================== */