Author: remy.maucherat(a)jboss.com
Date: 2008-08-25 06:58:38 -0400 (Mon, 25 Aug 2008)
New Revision: 745
Modified:
trunk/native/connector/src/address.c
trunk/native/connector/src/info.c
Log:
- Keep the native code in sync.
Modified: trunk/native/connector/src/address.c
===================================================================
--- trunk/native/connector/src/address.c 2008-08-18 12:47:01 UTC (rev 744)
+++ trunk/native/connector/src/address.c 2008-08-25 10:58:38 UTC (rev 745)
@@ -30,6 +30,7 @@
apr_pool_t *p = J2P(pool, apr_pool_t *);
TCN_ALLOC_CSTRING(hostname);
apr_sockaddr_t *sa = NULL;
+ apr_sockaddr_t *sl = NULL;
apr_int32_t f;
@@ -38,10 +39,26 @@
TCN_THROW_IF_ERR(apr_sockaddr_info_get(&sa,
J2S(hostname), f, (apr_port_t)port,
(apr_int32_t)flags, p), sa);
+ sl = sa;
+ /*
+ * apr_sockaddr_info_get may return several address so this is not
+ * go to work in some cases (but as least it works for Linux)
+ * XXX: with AP_ENABLE_V4_MAPPED it is going to work otherwise it won't.
+ */
+#if APR_HAVE_IPV6
+ if (hostname == NULL) {
+ /* Try all address using IPV6 one */
+ while (sl) {
+ if (sl->family == APR_INET6)
+ break; /* Done */
+ sl = sl->next;
+ }
+ }
+#endif
cleanup:
TCN_FREE_CSTRING(hostname);
- return P2J(sa);
+ return P2J(sl);
}
TCN_IMPLEMENT_CALL(jstring, Address, getnameinfo)(TCN_STDARGS,
Modified: trunk/native/connector/src/info.c
===================================================================
--- trunk/native/connector/src/info.c 2008-08-18 12:47:01 UTC (rev 744)
+++ trunk/native/connector/src/info.c 2008-08-25 10:58:38 UTC (rev 745)
@@ -200,12 +200,17 @@
static void fill_ainfo(JNIEnv *e, jobject obj, apr_sockaddr_t *info)
{
+ apr_int32_t f;
+ if (info->family == APR_UNSPEC) f = 0;
+ else if (info->family == APR_INET) f = 1;
+ else if (info->family == APR_INET6) f = 2;
+ else f = info->family;
SET_AINFO_J(pool, P2J(info->pool));
SET_AINFO_S(hostname, info->hostname);
SET_AINFO_S(servname, info->servname);
SET_AINFO_I(port, info->port);
- SET_AINFO_I(family, info->family);
+ SET_AINFO_I(family, f);
SET_AINFO_J(next, P2J(info->next));
}
Show replies by date