Fix available_fds when there is no AF_INET, reported by Mathieu Arnold.

This commit is contained in:
Nicholas Marriott 2015-10-15 09:24:25 +01:00
parent 7120ab2f16
commit f199fb6a2b

View File

@ -51,10 +51,14 @@ available_fds(unsigned int n)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
fds[i] = -1; fds[i] = -1;
if ((fds[i] = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { if ((fds[i] = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)
fds[i] = socket(AF_INET6, SOCK_DGRAM, 0);
if (fds[i] < 0) {
ret = 1; ret = 1;
break; break;
} }
} }
}
for (i = 0; i < n && fds[i] >= 0; i++) for (i = 0; i < n && fds[i] >= 0; i++)
close(fds[i]); close(fds[i]);