18287627 ntpd sometimes logs unexpected getifaddrs errors
authorBrian Utterback <brian.utterback@oracle.com>
Tue, 15 Jul 2014 07:20:42 -0700
changeset 2003 81f9a60cccb1
parent 2002 5d0b96773c16
child 2004 2a230bc62c46
18287627 ntpd sometimes logs unexpected getifaddrs errors
components/ntp/patches/85-getif-eintr.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ntp/patches/85-getif-eintr.patch	Tue Jul 15 07:20:42 2014 -0700
@@ -0,0 +1,47 @@
+If getifaddrs blocks on a lock and a SIGALRM happens to fire while it
+is block, it will return with EINTR. WE need to detect that and just
+try again.
+
+This is NTP bug 2565. Remove this patch when upgrading to a version that
+has bug 2565 fixed in it.
+
+--- lib/isc/unix/ifiter_getifaddrs.c
++++ lib/isc/unix/ifiter_getifaddrs.c
+@@ -55,6 +55,8 @@ isc_interfaceiter_create(isc_mem_t *mctx
+ 	isc_interfaceiter_t *iter;
+ 	isc_result_t result;
+ 	char strbuf[ISC_STRERRORSIZE];
++	int trys;
++	int ret;
+ 
+ 	REQUIRE(mctx != NULL);
+ 	REQUIRE(iterp != NULL);
+@@ -86,15 +88,21 @@ isc_interfaceiter_create(isc_mem_t *mctx
+ 	iter->valid = ISC_R_FAILURE;
+ #endif
+ 
+-	if (getifaddrs(&iter->ifaddrs) < 0) {
++	for (trys = 0; trys < 3; trys++) {
++		if ((ret = getifaddrs(&iter->ifaddrs)) >= 0)
++			break;
++		if (errno != EINTR) 
++			break;
++	}
++	if (ret < 0) {
+ 		isc__strerror(errno, strbuf, sizeof(strbuf));
+ 		UNEXPECTED_ERROR(__FILE__, __LINE__,
+-				 isc_msgcat_get(isc_msgcat,
+-						ISC_MSGSET_IFITERGETIFADDRS,
+-						ISC_MSG_GETIFADDRS,
+-						"getting interface "
+-						"addresses: getifaddrs: %s"),
+-				 strbuf);
++		    isc_msgcat_get(isc_msgcat,
++		    ISC_MSGSET_IFITERGETIFADDRS,
++		    ISC_MSG_GETIFADDRS,
++		    "getting interface "
++		    "addresses: getifaddrs: %s"),
++		    strbuf);
+ 		result = ISC_R_UNEXPECTED;
+ 		goto failure;
+ 	}