db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r497748 - in /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda: ClientThread.java DDMReader.java DRDAConnThread.java DRDAProtocolException.java
Date Fri, 19 Jan 2007 09:13:11 GMT
Author: bernt
Date: Fri Jan 19 01:13:10 2007
New Revision: 497748

URL: http://svn.apache.org/viewvc?view=rev&rev=497748
Log:
DERBY-2166 Implement proper handling of SocketTimeoutException in DRDAConnThread. Submitted
by Bernt M. Johnsen

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java?view=diff&rev=497748&r1=497747&r2=497748
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java Fri Jan 19
01:13:10 2007
@@ -62,8 +62,9 @@
 						}
 					 );
 							clientSocket.setKeepAlive(parent.getKeepAlive());
-					//set time out					
-					//this looks highly suspect.  Why does timeSlice setSoTimeout?		
+
+					// Set time out: Stops DDMReader.fill() from
+					// waiting indefinitely when timeSlice is set.
 					if (timeSlice != 0)
 						clientSocket.setSoTimeout(timeSlice);
 				} catch (PrivilegedActionException e) {

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java?view=diff&rev=497748&r1=497747&r2=497748
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java Fri Jan 19 01:13:10
2007
@@ -1896,12 +1896,16 @@
 			try {
 				actualBytesRead = inputStream.read (
 				  buffer, count, buffer.length - count);
-			}
-			catch (java.io.IOException ioe) {
-				agent.markCommunicationsFailure ("DDMReader.fill()",
-				  "InputStream.read()", ioe.getMessage(), "*");
-			}
-			finally {
+			} catch (java.net.SocketTimeoutException ste) {
+
+                // Transport the timeout out through the layers. This
+                // exception is caught in DRDAConnThread.run();
+                throw new DRDASocketTimeoutException(agent);
+
+			} catch (java.io.IOException ioe) {
+                agent.markCommunicationsFailure("DDMReader.fill()",
+                                                "InputStream.read()", ioe.getMessage(), "*");
+			} finally {
 				if ((dssTrace != null) && dssTrace.isComBufferTraceOn())
 				  dssTrace.writeComBufferData (buffer,
 				                               count,
@@ -1917,8 +1921,8 @@
 				totalBytesRead += actualBytesRead;
 			}
 
-		}
-		while ((totalBytesRead < minimumBytesNeeded) && (actualBytesRead != -1));
+		} while ((totalBytesRead < minimumBytesNeeded) && (actualBytesRead != -1));
+
 		if (actualBytesRead == -1) 
 		{
 			if (totalBytesRead < minimumBytesNeeded) 

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?view=diff&rev=497748&r1=497747&r2=497748
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Fri Jan 19
01:13:10 2007
@@ -272,7 +272,14 @@
 						long currentTimeSlice;
 
 						do {
-							processCommands();
+                            try {
+                                processCommands();
+                            } catch (DRDASocketTimeoutException ste) {
+                                // Just ignore the exception. This was
+                                // a timeout on the read call in
+                                // DDMReader.fill(), which will happen
+                                // only when timeSlice is set.
+                            }
 							currentTimeSlice = getTimeSlice();
 						} while ((currentTimeSlice == 0)  || 
 							(System.currentTimeMillis() - timeStart < currentTimeSlice));

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java?view=diff&rev=497748&r1=497747&r2=497748
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java Fri
Jan 19 01:13:10 2007
@@ -101,6 +101,7 @@
 
 	protected static String DRDA_Disconnect=	   "DRDA_Disconnect";
 	protected static String DRDA_AgentError=	   "DRDA_AgentError";
+    protected static String DRDA_Timeout=          "DRDA_Timeout";
 
 	static {
 	/* Create the errorInfoTable
@@ -201,6 +202,14 @@
 							 NO_ASSOC_ERRCD,
 							 false));
 
+
+	errorInfoTable.put(DRDA_Timeout,
+			   new DRDAProtocolExceptionInfo(
+							 0,
+							 0,
+							 NO_ASSOC_ERRCD,
+							 false));
+
 	}
 		
 	
@@ -387,7 +396,13 @@
 }
 
 
-
-
-
-
+/**
+ * Class used to transport that fact that we had a timeout and should
+ * *NOT* disconnect the connection.
+ * See DRDAConnThread.run()
+ */
+class DRDASocketTimeoutException extends DRDAProtocolException {
+    DRDASocketTimeoutException(DRDAConnThread t) {
+        super(DRDA_Timeout,t,0,0);
+    }
+}



Mime
View raw message