This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new f505e38 Simplify AprEndpoint socket bind for all platforms
f505e38 is described below
commit f505e38f91cdf3a59affa011f316f6cca9655086
Author: Michael Osipov <[email protected]>
AuthorDate: Sat May 22 13:36:57 2021 +0200
Simplify AprEndpoint socket bind for all platforms
* Unconditionally use APR_UNSPEC on all platforms and especially on *BSD
which
runs fine on IPv4 and IPv6 hosts.
socket address is of family APR_INET6.
This mimics the behavior of HTTPd's listen.c for apr_sockaddr_info_get()
along
with open_listeners() and make_sock().
---
java/org/apache/tomcat/util/net/AprEndpoint.java | 14 +++-----------
test/org/apache/tomcat/util/net/TestXxxEndpoint.java | 6 +-----
webapps/docs/changelog.xml | 3 +++
3 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java
b/java/org/apache/tomcat/util/net/AprEndpoint.java
index 6226aee..3d15a6a 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -472,21 +472,13 @@ public class AprEndpoint extends AbstractEndpoint<Long> {
if (getAddress() != null) {
addressStr = getAddress().getHostAddress();
}
- int family = Socket.APR_INET;
- if (Library.APR_HAVE_IPV6) {
- if (addressStr == null) {
- if (!OS.IS_BSD && !OS.IS_WIN32 && !OS.IS_WIN64) {
- family = Socket.APR_UNSPEC;
- }
- } else if (addressStr.indexOf(':') >= 0) {
- family = Socket.APR_UNSPEC;
- }
- }
+ int family = Socket.APR_UNSPEC;
long inetAddress = Address.info(addressStr, family,
getPort(), 0, rootPool);
// Create the APR server socket
- serverSock = Socket.create(Address.getInfo(inetAddress).family,
+ int saFamily = Address.getInfo(inetAddress).family;
+ serverSock = Socket.create(saFamily,
Socket.SOCK_STREAM,
Socket.APR_PROTO_TCP, rootPool);
if (OS.IS_UNIX) {
diff --git a/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
b/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
index 128a3e2..79ed04d 100644
--- a/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
+++ b/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
@@ -64,11 +64,7 @@ public class TestXxxEndpoint extends TomcatBaseTest {
String address = InetAddress.getByName("localhost").getHostAddress();
// Create the APR address that will be bound
- int family = Socket.APR_INET;
- if (Library.APR_HAVE_IPV6) {
- if (!OS.IS_BSD && !OS.IS_WIN32 && !OS.IS_WIN64)
- family = Socket.APR_UNSPEC;
- }
+ int family = Socket.APR_UNSPEC;
long inetAddress = 0;
try {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bbfc78a..c0ae266 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -137,6 +137,9 @@
Fix failing to run any tests on Windows with Java 8u292 onwards.
(markt/kkolinko)
</fix>
+ <update>
+ Simplify AprEndpoint socket bind for all platforms. (michaelo)
+ </update>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]