Commit 96b8c245 authored by Andre Freyssinet's avatar Andre Freyssinet

Bug fix [JORAM-376]: Allows to configure SO_LINGER on JNDI socket.

parent de028c6f
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2021 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -51,7 +51,7 @@ public class IOControl {
public static final int DEFAULT_SO_TIMEOUT = 5000;
/**
* Enable/disable SO_TIMEOUT with the specified timeout in milliseconds.
* Enable/disable SO_TIMEOUT with the specified timeout in milliseconds.
* The default value is zero which means the option is disabled.
* This value can be adjusted by setting the environment property
* <code>fr.dyade.aaa.jndi2.socketTimeOut</code>.
......@@ -59,8 +59,15 @@ public class IOControl {
* InputStream associated with this Socket will block for only this amount
* of time.
*/
private static int socketTimeOut =
Configuration.getInteger(SO_TIMEOUT_PROP, DEFAULT_SO_TIMEOUT).intValue();
private static int socketTimeOut = Configuration.getInteger(SO_TIMEOUT_PROP, DEFAULT_SO_TIMEOUT).intValue();
public static final String SO_LINGER_PROP = "fr.dyade.aaa.jndi2.socketLinger";
/**
* Enable SO_LINGER with the specified linger time in seconds, if the
* value is less than 0 then it disables SO_LINGER. Default value is -1.
*/
private static int socketLinger = Configuration.getInteger(SO_LINGER_PROP, -1).intValue();
private Socket socket;
......@@ -72,7 +79,8 @@ public class IOControl {
this.socket = socket;
socket.setTcpNoDelay(true);
socket.setSoTimeout(socketTimeOut);
socket.setSoLinger(true, 1000);
if (socketLinger > 0)
socket.setSoLinger(true, socketLinger);
nos = new NetOutputStream(socket);
bis = new BufferedInputStream(socket.getInputStream());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment