db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r511353 - /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Date Sat, 24 Feb 2007 21:26:25 GMT
Author: djd
Date: Sat Feb 24 13:26:24 2007
New Revision: 511353

URL: http://svn.apache.org/viewvc?view=rev&rev=511353
Log:
DERBY-2369 Use a single socket for shutdown down the network server and the ping to ensure
it is shutdown. Reduce the sleep time between pings to allow faster recognition that the
server is down.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?view=diff&rev=511353&r1=511352&r2=511353
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Sat Feb 24 13:26:24 2007
@@ -144,8 +144,8 @@
 	private final static String DEFAULT_LOCALE_COUNTRY="US";
 
 	// Check up to 10 seconds to see if shutdown occurred
-	private final static int SHUTDOWN_CHECK_ATTEMPTS = 20;
-	private final static int SHUTDOWN_CHECK_INTERVAL= 500;
+	private final static int SHUTDOWN_CHECK_ATTEMPTS = 100;
+	private final static int SHUTDOWN_CHECK_INTERVAL= 100;
 
 	// maximum reply size
 	private final static int MAXREPLY = 32767;
@@ -878,7 +878,6 @@
 		writeCommandHeader(COMMAND_SHUTDOWN);
 		send();
 		readResult();
-        closeSocket();
 		// Wait up to 10 seconds for things to really shut down
 		// need a quiet ping so temporarily disable the logwriter
 		PrintWriter savWriter = logWriter;
@@ -896,17 +895,21 @@
 		{
 			Thread.sleep(SHUTDOWN_CHECK_INTERVAL);
 			try {
-				ping();
+                pingWithNoOpen();
 			} catch (Exception e) 
 			{
-				// as soon as we can't ping return
-				if (ntry == SHUTDOWN_CHECK_ATTEMPTS)
-					consolePropertyMessage("DRDA_ShutdownError.S", new String [] {
-						Integer.toString(portNumber), 
-						hostArg}); 
+                // as soon as we can't ping return
 				break;
 			}
 		}
+        closeSocket();
+        
+        
+        if (ntry == SHUTDOWN_CHECK_ATTEMPTS)
+            consolePropertyMessage("DRDA_ShutdownError.S", new String [] {
+                Integer.toString(portNumber), 
+                hostArg}); 
+        
 		logWriter= savWriter;
 		return;
 	}
@@ -938,8 +941,23 @@
 		return true;
 	}
 
+    /**
+     * Ping opening an new socket and close it.
+     * @throws Exception
+     */
 	public void ping() throws Exception
 	{
+        setUpSocket();
+        pingWithNoOpen();
+        closeSocket();
+    }
+    
+    /**
+     * Ping the server using the client socket that is already open.
+     */
+    private void pingWithNoOpen() throws Exception
+    {
+    
 		// database no longer used, but don't change the protocol 
 		// in case we add
 		// authorization  later.
@@ -947,15 +965,13 @@
 		String user = null;
 		String password = null;
 
-			setUpSocket();
+			
 			writeCommandHeader(COMMAND_TESTCONNECTION);
 			writeLDString(database);
 			writeLDString(user);
 			writeLDString(password);
 			send();
 			readResult();
-            closeSocket();
-
 	}
 
 



Mime
View raw message