Permalink
Browse files

Add support for TCP_NODELAY

  • Loading branch information...
namiles committed Nov 2, 2018
1 parent 908ae60 commit cf2e29f27e4a5ef2303a3a41aa88616c0525a534
@@ -564,8 +564,11 @@
* A Disabled value will not require a certificate chain for the Server Connection. A DisabledAll will not require a certificate chain for both Server and Client Connections.
* </li>
*
*<li><b>gov.nist.javax.sip.RELIABLE_CONNECTION_KEEP_ALIVE_TIMEOUT</b> Value in seconds which is used as default keepalive timeout
* (See also http://tools.ietf.org/html/rfc5626#section-4.4.1). Defaults to "infiinity" seconds (i.e. timeout event not delivered).</li>
* <li><b>gov.nist.javax.sip.RELIABLE_CONNECTION_KEEP_ALIVE_TIMEOUT</b> Value in seconds which is used as default keepalive timeout
* (See also http://tools.ietf.org/html/rfc5626#section-4.4.1). Defaults to "infinity" seconds (i.e. timeout event not delivered).</li>
*
* <li><b>gov.nist.javax.sip.TCP_NODELAY = [true|false]</b>
* Whether or not to disable Nagle's algorithm for TCP sockets. Defaults to {@code false}.</li>
*
* <li><b>gov.nist.javax.sip.SSL_HANDSHAKE_TIMEOUT</b> Value in seconds which is used as default timeout for performing the SSL Handshake
* This prevents bad clients of connecting without sending any data to block the server</li>
@@ -1103,6 +1106,12 @@ public SipStackImpl(Properties configurationProperties)
}
}
String isTcpNoDelayEnabled = configurationProperties
.getProperty("gov.nist.javax.sip.TCP_NODELAY");
if (isTcpNoDelayEnabled != null) {
this.isTcpNoDelayEnabled = Boolean.parseBoolean(isTcpNoDelayEnabled);
}
String serverTransactionTableSize = configurationProperties
.getProperty("gov.nist.javax.sip.MAX_SERVER_TRANSACTIONS");
if (serverTransactionTableSize != null) {
@@ -33,6 +33,7 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.*;
import java.util.*;
@@ -237,6 +238,11 @@ public void accept(SelectionKey selectionKey) throws IOException{
ServerSocketChannel serverSocketChannel = (ServerSocketChannel) selectionKey.channel();
SocketChannel client;
client = serverSocketChannel.accept();
if (sipStack.isTcpNoDelayEnabled) {
client.setOption(StandardSocketOptions.TCP_NODELAY, true);
}
client.configureBlocking(false);
if(logger.isLoggingEnabled(LogWriter.TRACE_DEBUG))
logger.logDebug("got a new connection! " + client);
@@ -351,6 +351,8 @@
protected boolean isDialogTerminatedEventDeliveredForNullDialog = false;
protected boolean isTcpNoDelayEnabled = false;
// Max time for a forked response to arrive. After this time, the original
// dialog
// is not tracked. If you want to track the original transaction you need to
@@ -122,6 +122,11 @@ public void run() {
}
Socket newsock = sock.accept();
if (sipStack.isTcpNoDelayEnabled) {
newsock.setTcpNoDelay(true);
}
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Accepting new connection!");
}
@@ -159,6 +159,9 @@ public void run() {
}
newsock = sock.accept();
if (sipStack.isTcpNoDelayEnabled) {
newsock.setTcpNoDelay(true);
}
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Accepting new connection!");

0 comments on commit cf2e29f

Please sign in to comment.