You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2021/11/23 17:43:13 UTC
[ignite] branch ignite-2.12 updated: IGNITE-15767 Fixed spontaneous SocketTimeoutException in server socket accept (JDK-8247750). (#9498)
This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch ignite-2.12
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-2.12 by this push:
new fd180c2 IGNITE-15767 Fixed spontaneous SocketTimeoutException in server socket accept (JDK-8247750). (#9498)
fd180c2 is described below
commit fd180c232ae886eaefb5425999c1e3f1bb8fbde2
Author: ibessonov <be...@gmail.com>
AuthorDate: Tue Nov 23 12:54:37 2021 +0300
IGNITE-15767 Fixed spontaneous SocketTimeoutException in server socket accept (JDK-8247750). (#9498)
(cherry picked from commit 7eb396c18db3b9ddf501f6554f9f7b5d330db0bc)
---
.../apache/ignite/internal/util/IgniteUtils.java | 22 ++++++++++++++++++++++
.../util/ipc/loopback/IpcServerTcpEndpoint.java | 3 ++-
.../ipc/shmem/IpcSharedMemoryServerEndpoint.java | 3 ++-
.../ignite/spi/discovery/tcp/ServerImpl.java | 2 +-
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index e06f11e..742cfd1 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -65,8 +65,10 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
+import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
+import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -12249,4 +12251,24 @@ public abstract class IgniteUtils {
return safeAbs(hash % size);
}
+ /**
+ * Invokes {@link ServerSocket#accept()} method on the passed server socked, working around the
+ * https://bugs.openjdk.java.net/browse/JDK-8247750 in the process.
+ *
+ * @param srvrSock Server socket.
+ * @return New socket.
+ * @throws IOException If an I/O error occurs when waiting for a connection.
+ * @see ServerSocket#accept()
+ */
+ public static Socket acceptServerSocket(ServerSocket srvrSock) throws IOException {
+ while (true) {
+ try {
+ return srvrSock.accept();
+ }
+ catch (SocketTimeoutException e) {
+ if (srvrSock.getSoTimeout() > 0)
+ throw e;
+ }
+ }
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/loopback/IpcServerTcpEndpoint.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/loopback/IpcServerTcpEndpoint.java
index 2b193ee..b4e9965 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/loopback/IpcServerTcpEndpoint.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/loopback/IpcServerTcpEndpoint.java
@@ -24,6 +24,7 @@ import java.net.Socket;
import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.ipc.IpcEndpoint;
import org.apache.ignite.internal.util.ipc.IpcEndpointBindException;
import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
@@ -81,7 +82,7 @@ public class IpcServerTcpEndpoint implements IpcServerEndpoint {
/** {@inheritDoc} */
@Override public IpcEndpoint accept() throws IgniteCheckedException {
try {
- Socket sock = srvSock.accept();
+ Socket sock = IgniteUtils.acceptServerSocket(srvSock);
return new IpcClientTcpEndpoint(sock);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
index b85228c..2b0ff94 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
@@ -40,6 +40,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.ipc.IpcEndpoint;
import org.apache.ignite.internal.util.ipc.IpcEndpointBindException;
import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
@@ -225,7 +226,7 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
boolean accepted = false;
try {
- sock = srvSock.accept();
+ sock = IgniteUtils.acceptServerSocket(srvSock);
accepted = true;
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 37518c9..131ec8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -6650,7 +6650,7 @@ class ServerImpl extends TcpDiscoveryImpl {
blockingSectionBegin();
try {
- sock = srvrSock.accept();
+ sock = IgniteUtils.acceptServerSocket(srvrSock);
}
finally {
blockingSectionEnd();