This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
The following commit(s) were added to refs/heads/main by this push:
new 420cd1c Simplify Address#getInfo() native implementation
420cd1c is described below
commit 420cd1c159e4f27bb5d2a873dbd1fb7ea5d3473c
Author: Michael Osipov <[email protected]>
AuthorDate: Fri May 21 23:31:14 2021 +0200
Simplify Address#getInfo() native implementation
Don't apply tricks and rely on OS behavior to resolve addresses. It is the
caller's responsibility to properly process socket addresses if more than
one exists.
This mimics the behavior of HTTPd's listen.c for apr_sockaddr_info_get().
---
native/src/address.c | 42 +--------------------------------------
xdocs/miscellaneous/changelog.xml | 5 +++++
2 files changed, 6 insertions(+), 41 deletions(-)
diff --git a/native/src/address.c b/native/src/address.c
index 87a8771..fb17431 100644
--- a/native/src/address.c
+++ b/native/src/address.c
@@ -23,59 +23,19 @@ TCN_IMPLEMENT_CALL(jlong, Address, info)(TCN_STDARGS,
{
apr_pool_t *p = J2P(pool, apr_pool_t *);
TCN_ALLOC_CSTRING(hostname);
- char *sp = NULL;
- int scope_id = 0;
apr_sockaddr_t *sa = NULL;
- apr_sockaddr_t *sl = NULL;
apr_int32_t f;
UNREFERENCED(o);
GET_S_FAMILY(f, family);
-#if APR_HAVE_IPV6
- if (hostname) {
- /* XXX: This only works for real scope_id's
- */
- if ((sp = strchr(J2S(hostname), '%'))) {
- *sp++ = '\0';
- scope_id = atoi(sp);
- }
- }
-#endif
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;
- }
- /* If we don't find an IPv6 address, use the original one */
- if (sl == NULL) {
- sl = sa;
- }
- }
- if (sp) {
- /* Set the provided scope id
- * APR lack the api for setting this directly so lets presume
- * the sin6_scope_id is present everywhere
- */
- sl->sa.sin6.sin6_scope_id = scope_id;
- }
-#endif
cleanup:
TCN_FREE_CSTRING(hostname);
- return P2J(sl);
+ return P2J(sa);
}
TCN_IMPLEMENT_CALL(jstring, Address, getnameinfo)(TCN_STDARGS,
diff --git a/xdocs/miscellaneous/changelog.xml
b/xdocs/miscellaneous/changelog.xml
index 9f35b6e..c735980 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -35,6 +35,11 @@
</p>
</section>
<section name="Changes in 1.2.29">
+ <changelog>
+ <update>
+ Simplify <code>Address.getInfo()<code> native implementation. (michaelo)
+ </update>
+ </changelog>
</section>
<section name="Changes in 1.2.28">
<changelog>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]