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

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

commit d66c3dda78a37fcc81fdb7615e368b4f67c171f1
Author: johnnyv <john...@apache.org>
AuthorDate: Wed Apr 15 17:55:57 2020 -0400

    Merge bugfix/DIRMINA-1123
    
    Configures the SND/RCV socket buffer before bind()
---
 .../mina/transport/socket/nio/NioSocketAcceptor.java       | 14 ++++++++++++++
 1 file changed, 14 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..5090d78 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) {
@@ -245,6 +249,16 @@ 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 {

Reply via email to