Author: kmarsden
Date: Fri Dec 2 18:02:13 2011
New Revision: 1209609
URL: http://svn.apache.org/viewvc?rev=1209609&view=rev
Log:
DERBY-5347 On z/OS Derby loops filling logs and consuming all CPU with repeated
error: java.net.SocketException: EDC5122I Input/output error.
Modified:
db/derby/code/branches/10.7/ (props changed)
db/derby/code/branches/10.7/java/drda/org/apache/derby/impl/drda/ClientThread.java
Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 2 18:02:13 2011
@@ -1,2 +1,2 @@
-/db/derby/code/branches/10.8:1209228,1209284
+/db/derby/code/branches/10.8:1209227-1209228,1209284
/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076335,1076387,1078461,1078608,1078693,1081072,1081455,1081568,1085078,1091000,1097247,1103681,1103718,1128243,1129136,1130632,1130895,1131272,1132664,1136363,1138341,1138444,1139449,1141924,1164370,1203050,1207729,1208775,1209228
Modified: db/derby/code/branches/10.7/java/drda/org/apache/derby/impl/drda/ClientThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/drda/org/apache/derby/impl/drda/ClientThread.java?rev=1209609&r1=1209608&r2=1209609&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/drda/org/apache/derby/impl/drda/ClientThread.java (original)
+++ db/derby/code/branches/10.7/java/drda/org/apache/derby/impl/drda/ClientThread.java Fri
Dec 2 18:02:13 2011
@@ -57,22 +57,15 @@ final class ClientThread extends Thread
try { // Check for underlying InterruptedException,
// SSLException and IOException
- try{ // Check for PrivilegedActionException
-
- clientSocket =
- (Socket) AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws IOException
- {
- return serverSocket.accept();
- }
- }
- );
+ try { // Check for PrivilegedActionException
+ clientSocket =
+ acceptClientWithRetry();
// Server may have been shut down. If so, close this
// client socket and break out of the loop.
// DERBY-3869
if (parent.getShutdown()) {
- clientSocket.close();
+ if (clientSocket != null)
+ clientSocket.close();
return;
}
@@ -149,6 +142,52 @@ final class ClientThread extends Thread
} // end for(;;)
}// end run()
+
+ /**
+ * Perform a server socket accept. Allow three attempts with a one second
+ * wait between each
+ *
+ * @return client socket or null if accept failed.
+ *
+ */
+ private Socket acceptClientWithRetry() {
+ return (Socket) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ for (int trycount = 1; trycount <= 3; trycount++) {
+ try {
+ // DERBY-5347 Need to exit if
+ // accept fails with IOException
+ // Cannot just aimlessly loop
+ // writing errors
+ return serverSocket.accept();
+ } catch (IOException acceptE) {
+ // If not a normal shutdown,
+ // log and shutdown the server
+ if (!parent.getShutdown()) {
+ parent
+ .consoleExceptionPrintTrace(acceptE);
+ if (trycount == 3) {
+ // give up after three tries
+ parent.directShutdownInternal();
+ } else {
+ // otherwise wait 1 second and retry
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ parent
+ .consoleExceptionPrintTrace(ie);
+ }
+ }
+ }
+ }
+ }
+ return null; // no socket to return after three tries
+ }
+ }
+
+ );
+ }
}
|