1 If getifaddrs blocks on a lock and a SIGALRM happens to fire while it |
|
2 is block, it will return with EINTR. WE need to detect that and just |
|
3 try again. |
|
4 |
|
5 This is NTP bug 2565. Remove this patch when upgrading to a version that |
|
6 has bug 2565 fixed in it. |
|
7 |
|
8 --- lib/isc/unix/ifiter_getifaddrs.c |
|
9 +++ lib/isc/unix/ifiter_getifaddrs.c |
|
10 @@ -55,6 +55,8 @@ isc_interfaceiter_create(isc_mem_t *mctx |
|
11 isc_interfaceiter_t *iter; |
|
12 isc_result_t result; |
|
13 char strbuf[ISC_STRERRORSIZE]; |
|
14 + int trys; |
|
15 + int ret; |
|
16 |
|
17 REQUIRE(mctx != NULL); |
|
18 REQUIRE(iterp != NULL); |
|
19 @@ -86,15 +88,21 @@ isc_interfaceiter_create(isc_mem_t *mctx |
|
20 iter->valid = ISC_R_FAILURE; |
|
21 #endif |
|
22 |
|
23 - if (getifaddrs(&iter->ifaddrs) < 0) { |
|
24 + for (trys = 0; trys < 3; trys++) { |
|
25 + if ((ret = getifaddrs(&iter->ifaddrs)) >= 0) |
|
26 + break; |
|
27 + if (errno != EINTR) |
|
28 + break; |
|
29 + } |
|
30 + if (ret < 0) { |
|
31 isc__strerror(errno, strbuf, sizeof(strbuf)); |
|
32 UNEXPECTED_ERROR(__FILE__, __LINE__, |
|
33 - isc_msgcat_get(isc_msgcat, |
|
34 - ISC_MSGSET_IFITERGETIFADDRS, |
|
35 - ISC_MSG_GETIFADDRS, |
|
36 - "getting interface " |
|
37 - "addresses: getifaddrs: %s"), |
|
38 - strbuf); |
|
39 + isc_msgcat_get(isc_msgcat, |
|
40 + ISC_MSGSET_IFITERGETIFADDRS, |
|
41 + ISC_MSG_GETIFADDRS, |
|
42 + "getting interface " |
|
43 + "addresses: getifaddrs: %s"), |
|
44 + strbuf); |
|
45 result = ISC_R_UNEXPECTED; |
|
46 goto failure; |
|
47 } |
|