Bug 1109940 - Wrap Android DNS resolver functions. r=glandium, a=sledru
authorEugen Sawin <esawin@mozilla.com>
Mon, 15 Dec 2014 17:05:58 +0100
changeset 244657 856412935fe269d30f5fc846bc3f69f444679785
parent 244656 ff2800050eadbc8d933bab95ad90b5202f945a4e
child 244658 314f2b8b572b78625d75118ba429c752bd7618a2
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, sledru
bugs1109940
milestone36.0a2
Bug 1109940 - Wrap Android DNS resolver functions. r=glandium, a=sledru
configure.in
other-licenses/android/getaddrinfo.c
--- a/configure.in
+++ b/configure.in
@@ -7298,16 +7298,19 @@ AC_SUBST_LIST(WIN32_CRT_LIBS)
 
 dnl We need to wrap dlopen and related functions on Android because we use
 dnl our own linker.
 if test "$OS_TARGET" = Android; then
     MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
     if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
         MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=pthread_create,--wrap=epoll_wait,--wrap=poll,--wrap=pthread_cond_timedwait,--wrap=__pthread_cond_timedwait,--wrap=pthread_cond_wait,--wrap=epoll_create,--wrap=epoll_ctl,--wrap=close,--wrap=pthread_key_create,--wrap=pthread_key_delete,--wrap=socketpair,--wrap=pthread_self,--wrap=pthread_mutex_lock,--wrap=pthread_join,--wrap=pipe,--wrap=pipe2"
     fi
+    if test "$MOZ_WIDGET_TOOLKIT" = android; then
+        MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
+    fi
 fi
 
 AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
 export MOZ_GLUE_WRAP_LDFLAGS
 
 dnl ========================================================
 dnl = Use JS Call tracing
 dnl ========================================================
--- a/other-licenses/android/getaddrinfo.c
+++ b/other-licenses/android/getaddrinfo.c
@@ -402,21 +402,21 @@ do { 								\
 	((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || 	\
 	    (y) == PF_UNSPEC)))
 #define MATCH(x, y, w) 							\
 	((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
 
 #pragma GCC visibility push(default)
 
 extern const char *
-gai_strerror(int ecode);
+__wrap_gai_strerror(int ecode);
 extern void
-freeaddrinfo(struct addrinfo *ai);
+__wrap_freeaddrinfo(struct addrinfo *ai);
 extern int
-getaddrinfo(const char *hostname, const char *servname,
+__wrap_getaddrinfo(const char *hostname, const char *servname,
     const struct addrinfo *hints, struct addrinfo **res);
 
 int android_sdk_version;
 
 #pragma GCC visibility pop
 
 int android_sdk_version = -1;
 
@@ -426,27 +426,27 @@ static int honeycomb_or_later()
 	__android_log_print(ANDROID_LOG_INFO, "getaddrinfo",
 		"I am%s Honeycomb\n",
 		(android_sdk_version >= 11) ? "" : " not");
 #endif
 	return android_sdk_version >= 11;
 }
 
 const char *
-gai_strerror(int ecode)
+__wrap_gai_strerror(int ecode)
 {
 	if (honeycomb_or_later())
 		return gai_strerror(ecode);
 	if (ecode < 0 || ecode > EAI_MAX)
 		ecode = EAI_MAX;
 	return ai_errlist[ecode];
 }
 
 void
-freeaddrinfo(struct addrinfo *ai)
+__wrap_freeaddrinfo(struct addrinfo *ai)
 {
 	struct addrinfo *next;
 
 	if (honeycomb_or_later()) {
 		freeaddrinfo(ai);
 		return;
 	}
 
@@ -528,17 +528,17 @@ static int
 		.sin_family = AF_INET,
 		.sin_addr.s_addr = __constant_htonl(0x08080808L)  // 8.8.8.8
 	};
         sockaddr_union addr = { .in = sin_test };
         return _test_connect(PF_INET, &addr.generic, sizeof(addr.in));
 }
 
 int
-getaddrinfo(const char *hostname, const char *servname,
+__wrap_getaddrinfo(const char *hostname, const char *servname,
     const struct addrinfo *hints, struct addrinfo **res)
 {
 	struct addrinfo sentinel;
 	struct addrinfo *cur;
 	int error = 0;
 	struct addrinfo ai;
 	struct addrinfo ai0;
 	struct addrinfo *pai;
@@ -726,17 +726,17 @@ getaddrinfo(const char *hostname, const 
 			*res = sentinel.ai_next;
 			return SUCCESS;
 		} else
 			error = EAI_FAIL;
 	}
  free:
  bad:
 	if (sentinel.ai_next)
-		freeaddrinfo(sentinel.ai_next);
+		__wrap_freeaddrinfo(sentinel.ai_next);
 	*res = NULL;
 	return error;
 }
 
 /*
  * FQDN hostname, DNS lookup
  */
 static int
@@ -787,17 +787,17 @@ explore_fqdn(const struct addrinfo *pai,
 	}
 
 	*res = result;
 
 	return 0;
 
 free:
 	if (result)
-		freeaddrinfo(result);
+		__wrap_freeaddrinfo(result);
 	return error;
 }
 
 /*
  * hostname == NULL.
  * passive socket -> anyaddr (0.0.0.0 or ::)
  * non-passive socket -> localhost (127.0.0.1 or ::1)
  */
@@ -855,17 +855,17 @@ explore_null(const struct addrinfo *pai,
 	}
 	cur = cur->ai_next;
 
 	*res = sentinel.ai_next;
 	return 0;
 
 free:
 	if (sentinel.ai_next)
-		freeaddrinfo(sentinel.ai_next);
+		__wrap_freeaddrinfo(sentinel.ai_next);
 	return error;
 }
 
 /*
  * numeric hostname
  */
 static int
 explore_numeric(const struct addrinfo *pai, const char *hostname,
@@ -942,17 +942,17 @@ explore_numeric(const struct addrinfo *p
 	}
 
 	*res = sentinel.ai_next;
 	return 0;
 
 free:
 bad:
 	if (sentinel.ai_next)
-		freeaddrinfo(sentinel.ai_next);
+		__wrap_freeaddrinfo(sentinel.ai_next);
 	return error;
 }
 
 /*
  * numeric hostname with scope
  */
 static int
 explore_numeric_scope(const struct addrinfo *pai, const char *hostname,
@@ -2000,26 +2000,26 @@ static struct addrinfo *
 		if (strcasecmp(name, tname) == 0)
 			goto found;
 	}
 	goto again;
 
 found:
 	hints = *pai;
 	hints.ai_flags = AI_NUMERICHOST;
-	error = getaddrinfo(addr, NULL, &hints, &res0);
+	error = __wrap_getaddrinfo(addr, NULL, &hints, &res0);
 	if (error)
 		goto again;
 	for (res = res0; res; res = res->ai_next) {
 		/* cover it up */
 		res->ai_flags = pai->ai_flags;
 
 		if (pai->ai_flags & AI_CANONNAME) {
 			if (get_canonname(pai, res, cname) != 0) {
-				freeaddrinfo(res0);
+				__wrap_freeaddrinfo(res0);
 				goto again;
 			}
 		}
 	}
 	return res0;
 }
 
 /*ARGSUSED*/