Fix TcpDiscovery locks forever on SSLSocket.close() - Fixes
@@ -279,6 +279,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
/** Maximum ack timeout value for receiving message acknowledgement in milliseconds (value is <tt>600,000ms</tt>). */
public static final long DFLT_MAX_ACK_TIMEOUT = 10 * 60 * 1000;
+ /** Default SO_LINGER to set for socket, 0 means enabled with 0 timeout. */
+ public static final int DFLT_SO_LINGER = 5;
+
/** Default connection recovery timeout in ms. */
public static final long DFLT_CONNECTION_RECOVERY_TIMEOUT = IgniteConfiguration.DFLT_FAILURE_DETECTION_TIMEOUT;
@@ -372,6 +375,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
/** Maximum message acknowledgement timeout. */
private long maxAckTimeout = DFLT_MAX_ACK_TIMEOUT;
+ /** Default SO_LINGER to use for socket. Set negative to disable, non-negative to enable, default is {@DFLT_SO_LINGER }. */
+ private int soLinger = DFLT_SO_LINGER;
+
/** IP finder clean frequency. */
protected long ipFinderCleanFreq = DFLT_IP_FINDER_CLEAN_FREQ;
@@ -919,6 +925,17 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
return this;
}
+ /**
+ * Sets SO_LINGER to use for all created sockets.
+ * <p>
+ * If not specified, default is {@link #DFLT_SO_LINGER}
+ * </p>
+ */
+ @IgniteSpiConfiguration(optional = true)
+ public void setSoLinger(int soLinger) {
+ this.soLinger = soLinger;
+ }
+
/**
* Sets maximum network timeout to use for network operations.
* <p>
@@ -1253,6 +1270,15 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
return ackTimeout;
}
+ /**
+ * Gets SO_LINGER timeout for socket.
+ *
+ * @return SO_LINGER timeout for socket.
+ */
+ public int getSoLinger() {
+ return soLinger;
+ }
+
/**
* Gets network timeout.
*
@@ -1541,6 +1567,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
sock.setTcpNoDelay(true);
+ sock.setSoLinger(getSoLinger() >= 0, getSoLinger());
+
return sock;
} catch (IOException e) {
if (sock != null)
