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

elecharny pushed a commit to branch 2.0.X
in repository https://gitbox.apache.org/repos/asf/mina.git


The following commit(s) were added to refs/heads/2.0.X by this push:
     new ad6a0c8  Backported fix for DIRMINA-1123
ad6a0c8 is described below

commit ad6a0c867fca79f0fd45b67ab5b38dad22056e8a
Author: emmanuel lecharny <[email protected]>
AuthorDate: Mon Feb 7 23:50:21 2022 +0100

    Backported fix for DIRMINA-1123
---
 .../mina/transport/socket/nio/NioSocketAcceptor.java      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
 
b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
index f011ca1..b3def37 100644
--- 
a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
+++ 
b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.SocketAddress;
+import java.net.StandardSocketOptions;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.channels.ServerSocketChannel;
@@ -40,6 +41,7 @@ import org.apache.mina.core.service.SimpleIoProcessorPool;
 import org.apache.mina.core.service.TransportMetadata;
 import org.apache.mina.transport.socket.DefaultSocketSessionConfig;
 import org.apache.mina.transport.socket.SocketAcceptor;
+import org.apache.mina.transport.socket.SocketSessionConfig;
 
 /**
  * {@link IoAcceptor} for socket transport (TCP/IP).  This class
@@ -226,6 +228,8 @@ implements SocketAcceptor {
     protected ServerSocketChannel open(SocketAddress localAddress) throws 
Exception {
         // Creates the listening ServerSocket
 
+        SocketSessionConfig config = this.getSessionConfig();
+
         ServerSocketChannel channel = null;
 
         if (selectorProvider != null) {
@@ -246,6 +250,17 @@ implements SocketAcceptor {
             // Set the reuseAddress flag accordingly with the setting
             socket.setReuseAddress(isReuseAddress());
 
+            // Set the SND BUFF
+            if (config.getSendBufferSize() != -1) {
+                channel.setOption(StandardSocketOptions.SO_SNDBUF, 
config.getSendBufferSize());
+            }
+
+            // Set the RCV BUFF
+            if (config.getReceiveBufferSize() != -1) {
+                channel.setOption(StandardSocketOptions.SO_RCVBUF, 
config.getReceiveBufferSize());
+            }
+
+      
             // and bind.
             try {
                 socket.bind(localAddress, getBacklog());

Reply via email to