components/ntp/patches/85-getif-eintr.patch
author Gabriel Carrillo <gabriel.carrillo@oracle.com>
Fri, 26 Sep 2014 09:08:52 -0700
branchs11u2-sru-backport
changeset 3348 48f907ef15c8
parent 3221 e863b2da18cb
permissions -rw-r--r--
ips-buildinfo.mk for S11.2SRU2.8

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;
 	}