This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new ab1cdac358 Better logging for secure vs non-secure cluster 
configuration
ab1cdac358 is described below

commit ab1cdac358fe842bc3fafd28a830331ce6e77c39
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Sep 24 10:31:57 2026 +0100

    Better logging for secure vs non-secure cluster configuration
---
 .../catalina/tribes/group/TribesSslContext.java    |  9 ++++
 .../tribes/transport/LocalStrings.properties       |  2 +-
 .../catalina/tribes/transport/ReceiverBase.java    | 57 +++++++++++++---------
 .../catalina/tribes/transport/nio/NioReceiver.java |  4 +-
 4 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/java/org/apache/catalina/tribes/group/TribesSslContext.java 
b/java/org/apache/catalina/tribes/group/TribesSslContext.java
index d302bdfc34..4ab59fbd80 100644
--- a/java/org/apache/catalina/tribes/group/TribesSslContext.java
+++ b/java/org/apache/catalina/tribes/group/TribesSslContext.java
@@ -150,4 +150,13 @@ public class TribesSslContext implements AutoCloseable {
             }
         }
     }
+
+
+    public String getImplementationName() {
+        if (ffm) {
+            return "TLS-OpenSSL-FFM";
+        } else {
+            return "TLS-OpenSSL";
+        }
+    }
 }
diff --git a/java/org/apache/catalina/tribes/transport/LocalStrings.properties 
b/java/org/apache/catalina/tribes/transport/LocalStrings.properties
index 08d6f38ad4..88c4750b3d 100644
--- a/java/org/apache/catalina/tribes/transport/LocalStrings.properties
+++ b/java/org/apache/catalina/tribes/transport/LocalStrings.properties
@@ -22,7 +22,7 @@ pooledSender.closed.queue=Queue is closed
 
 receiverBase.address.unresolvable=Failed to resolve replication listener bind 
address [{0}]. The receiver start fails rather than binding to the wildcard 
address.
 receiverBase.bind.failed=Failed bind replication listener on address:[{0}]
-receiverBase.socket.bind=Receiver Server Socket bound to:[{0}]
+receiverBase.socket.bind=Receiver Server Socket bound to:[{0}] using [{1}]
 receiverBase.start=Starting replication listener on address [{0}]
 receiverBase.udp.bind=UDP Receiver Server Socket bound to:[{0}]
 receiverBase.unable.bind=Unable to bind server socket to:[{0}] throwing error.
diff --git a/java/org/apache/catalina/tribes/transport/ReceiverBase.java 
b/java/org/apache/catalina/tribes/transport/ReceiverBase.java
index 070435ac27..0c379d6136 100644
--- a/java/org/apache/catalina/tribes/transport/ReceiverBase.java
+++ b/java/org/apache/catalina/tribes/transport/ReceiverBase.java
@@ -33,6 +33,7 @@ import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelMessage;
 import org.apache.catalina.tribes.ChannelReceiver;
 import org.apache.catalina.tribes.MessageListener;
+import org.apache.catalina.tribes.group.GroupChannel;
 import org.apache.catalina.tribes.io.ListenCallback;
 import org.apache.catalina.tribes.jmx.JmxRegistry;
 import org.apache.catalina.tribes.util.ExecutorFactory;
@@ -248,8 +249,27 @@ public abstract class ReceiverBase implements 
ChannelReceiver, ListenCallback, R
      * @param retries   Number of times to attempt to bind (port incremented 
between attempts)
      *
      * @throws IOException Socket bind error
+     *
+     * @deprecated Use {@link #bind(ServerSocket, int, int, boolean)}. This 
method will be removed in Tomcat 12.
      */
+    @Deprecated
     protected void bind(ServerSocket socket, int portstart, int retries) 
throws IOException {
+        bind(socket, portstart, retries, false);
+    }
+
+    /**
+     * Attempts to bind using the provided port and if that fails attempts to 
bind to each of the ports from portstart
+     * to (portstart + retries -1) until either there are no more ports or the 
bind is successful. The address to bind
+     * to is obtained via a call to {@link #getBind()}.
+     *
+     * @param socket    The socket to bind
+     * @param portstart Starting port for bind attempts
+     * @param retries   Number of times to attempt to bind (port incremented 
between attempts)
+     * @param secure    Is this bind for a secure port or not
+     *
+     * @throws IOException Socket bind error
+     */
+    protected void bind(ServerSocket socket, int portstart, int retries, 
boolean secure) throws IOException {
         synchronized (bindLock) {
             InetAddress address = resolveBind();
             InetSocketAddress addr = null;
@@ -258,8 +278,19 @@ public abstract class ReceiverBase implements 
ChannelReceiver, ListenCallback, R
                 try {
                     addr = new InetSocketAddress(address, port);
                     socket.bind(addr);
-                    setPort(port);
-                    log.info(sm.getString("receiverBase.socket.bind", addr));
+                    String type;
+                    if (secure) {
+                        setSecurePort(port);
+                        if (getChannel() instanceof GroupChannel groupChannel) 
{
+                            type = 
groupChannel.getSslContext().getImplementationName();
+                        } else {
+                            type = "secure";
+                        }
+                    } else {
+                        type = "cleartext";
+                        setPort(port);
+                    }
+                    log.info(sm.getString("receiverBase.socket.bind", addr, 
type));
                     retries = 0;
                 } catch (IOException ioe) {
                     retries--;
@@ -275,28 +306,6 @@ public abstract class ReceiverBase implements 
ChannelReceiver, ListenCallback, R
         }
     }
 
-    protected void bindSecure(ServerSocket socket, int portstart, int retries) 
throws IOException {
-        synchronized (bindLock) {
-            InetSocketAddress address = null;
-            int port = portstart;
-            while (retries > 0) {
-                try {
-                    address = new InetSocketAddress(getBind(), port);
-                    socket.bind(address);
-                    setSecurePort(port);
-                    log.info(sm.getString("receiverBase.socket.bind", 
address));
-                    return;
-                } catch (IOException ioe) {
-                    if (--retries <= 0) {
-                        log.info(sm.getString("receiverBase.unable.bind", 
address));
-                        throw ioe;
-                    }
-                    port++;
-                }
-            }
-        }
-    }
-
     /**
      * Same as bind() except it does it for the UDP port
      *
diff --git a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java 
b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
index 7da08a7250..3dc61760be 100644
--- a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
+++ b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
@@ -98,7 +98,7 @@ public class NioReceiver extends ReceiverBase implements 
Runnable, NioReceiverMB
             return;
         }
         secureServerChannel = ServerSocketChannel.open();
-        bindSecure(secureServerChannel.socket(), getSecurePort(), 
getAutoBind());
+        bind(secureServerChannel.socket(), getSecurePort(), getAutoBind(), 
true);
         secureConnectionSlots = new Semaphore(Math.max(1, getMaxTasks()));
         Thread thread = new Thread(() -> 
runSecureListener(groupChannel.getSslContext()), "NioReceiver-TLS");
         thread.setDaemon(true);
@@ -280,7 +280,7 @@ public class NioReceiver extends ReceiverBase implements 
Runnable, NioReceiverMB
             this.selector.set(Selector.open());
             // set the port the server channel will listen to
             // serverSocket.bind(new InetSocketAddress(getBind(), 
getTcpListenPort()));
-            bind(serverSocket, getPort(), getAutoBind());
+            bind(serverSocket, getPort(), getAutoBind(), false);
             // set non-blocking mode for the listening socket
             serverChannel.configureBlocking(false);
             // register the ServerSocketChannel with the Selector


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to