michael-o commented on a change in pull request #401:
URL: https://github.com/apache/tomcat/pull/401#discussion_r563890291



##########
File path: java/org/apache/tomcat/util/net/AprEndpoint.java
##########
@@ -287,6 +312,9 @@ public int getSendfileCount() {
     @Override
     public void bind() throws Exception {
 
+        int family;
+        String hostname = null;

Review comment:
       Why is this variable called `hostname`? The AF-agnostic name is 
`address`, isn't it?

##########
File path: java/org/apache/tomcat/util/net/AprEndpoint.java
##########
@@ -296,52 +324,88 @@ public void bind() throws Exception {
 
         // Create the pool for the server socket
         serverSockPool = Pool.create(rootPool);
+
         // Create the APR address that will be bound
-        String addressStr = null;
-        if (getAddress() != null) {
-            addressStr = getAddress().getHostAddress();
-        }
-        int family = Socket.APR_INET;
-        if (Library.APR_HAVE_IPV6) {
-            if (addressStr == null) {
-                if (!OS.IS_BSD) {
+        if (getUnixDomainSocketPath() != null) {
+            if (Library.APR_HAVE_UNIX) {
+                hostname = getUnixDomainSocketPath();
+                family = Socket.APR_UNIX;
+            }
+            else {
+                throw new 
Exception(sm.getString("endpoint.init.unixnotavail"));
+            }
+        }
+        else {
+
+            if (getAddress() != null) {
+                hostname = getAddress().getHostAddress();

Review comment:
       same here, address != hostname.

##########
File path: test/org/apache/tomcat/jni/TestUnixDomainSocketServer.java
##########
@@ -0,0 +1,240 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.jni;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+/*
+ * Tests for unix domain sockets.
+ *
+ * While System.nanotime() is available and may have a resolution of ~100ns on
+ * some platforms, those same platforms do not use as precise a timer for 
socket
+ * timeouts. Therefore, a much larger error margin (100ms) is used.
+ *
+ * It is known that this larger error margin is required for Windows 10. It may
+ * be worth revisiting the choice of error margin once that platform is no
+ * longer supported.
+ *
+ * @deprecated  The scope of the APR/Native Library will be reduced in Tomcat
+ *              10.1.x onwards to only those components required to provide
+ *              OpenSSL integration with the NIO and NIO2 connectors.
+ */
+@Deprecated
+public class TestUnixDomainSocketServer extends AbstractJniTest {
+
+       private static final String PATH = System.getProperty("java.io.tmpdir") 
+ System.getProperty("file.separator") + "tomcat.socket";
+    // 100ms == 100,000,000ns
+    private static final long ERROR_MARGIN = 100000000;
+
+    private long pool = 0;
+    private long serverSocket = 0;
+    private long clientSocket = 0;
+
+    @Before
+    public void init() throws Exception {
+       Assume.assumeTrue(Library.APR_HAVE_UNIX);
+        pool = Pool.create(0);

Review comment:
       Indentation is inconsistent.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to