db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r442463 - in /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda: ClientThread.java DRDAConnThread.java NetworkServerControlImpl.java
Date Tue, 12 Sep 2006 05:57:42 GMT
Author: kahatlen
Date: Mon Sep 11 22:57:41 2006
New Revision: 442463

URL: http://svn.apache.org/viewvc?view=rev&rev=442463
Log:
DERBY-1817: Race condition in network server's thread pool

Clean-up of NetworkServerControlImpl:
  - moves generation of connection number into addSession()
  - adds new method removeThread() which can be used instead of
    getThreadList().remove()
  - removes methods that are no longer used
  - makes methods that are only used by NetworkServerControlImpl private

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/DRDAConnThread.java
    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/ClientThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java?view=diff&rev=442463&r1=442462&r2=442463
==============================================================================
--- 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 Mon Sep 11
22:57:41 2006
@@ -76,14 +76,9 @@
 					} else throw e1;
 	                		break;
 				} // end priv try/catch block
-				
-				connNum = parent.getNewConnNum();
-                                if (parent.getLogConnections())
-                                    parent.consolePropertyMessage("DRDA_ConnNumber.I", 
-							Integer.toString(connNum));
 
 				//create a new Session for this session
-				parent.addSession(connNum, clientSocket);
+				parent.addSession(clientSocket);
 
 				}catch (Exception e) {
 					if (e instanceof InterruptedException)

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=442463&r1=442462&r2=442463
==============================================================================
--- 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 Mon Sep 11
22:57:41 2006
@@ -292,7 +292,7 @@
 		}
 		if (SanityManager.DEBUG)
 			trace("Ending connection thread");
-		server.getThreadList().removeElement(this);
+		server.removeThread(this);
 
 	}
 	/**

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=442463&r1=442462&r2=442463
==============================================================================
--- 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
Mon Sep 11 22:57:41 2006
@@ -1856,7 +1856,7 @@
 	 *
 	 * @param clientSession	session needing work
 	 */
-	protected void runQueueAdd(Session clientSession)
+	private void runQueueAdd(Session clientSession)
 	{
 		synchronized(runQueue)
 		{
@@ -3094,7 +3094,7 @@
 	 *
 	 * @return value of maximum number of threads
 	 */
-	protected int getMaxThreads()
+	private int getMaxThreads()
 	{
 		synchronized(threadsSync) {
 			return maxThreads;
@@ -3378,11 +3378,19 @@
 	 * there are free threads, and the maximum number of threads is not
 	 * exceeded.
 	 *
-	 * @param connectionNumber number of connection
+	 * <p><code>addSession()</code> should only be called from one thread
at a
+	 * time.
+	 *
 	 * @param clientSocket the socket to read from and write to
 	 */
-	void addSession(int connectionNumber, Socket clientSocket)
-			throws IOException {
+	void addSession(Socket clientSocket) throws Exception {
+
+		int connectionNumber = ++connNum;
+
+		if (getLogConnections()) {
+			consolePropertyMessage("DRDA_ConnNumber.I",
+								   Integer.toString(connectionNumber));
+		}
 
 		// Note that we always re-fetch the tracing configuration because it
 		// may have changed (there are administrative commands which allow
@@ -3430,41 +3438,13 @@
 	}
 
 	/**
-	 * Get New Conn Num - for use by ClientThread, generate a new connection number for the
attempted Session.
-	 *
-	 * @return	a new connection number
-	 */
-	protected int getNewConnNum()
-	{
-		return ++connNum;
-	}
-
-
-	/**
-	 * Get Free Threads - for use by ClientThread, get the number of 
-	 * free threads in order to determine if
-	 * a new thread can be run.
+	 * Remove a thread from the thread list. Should be called when a
+	 * <code>DRDAConnThread</code> has been closed.
 	 *
-	 * @return	the number of free threads
+	 * @param thread the closed thread
 	 */
-	protected int getFreeThreads()
-	{
-		synchronized(runQueue)
-		{
-			return freeThreads;
-		}
-	}
-
-	/**
-	 * Get Thread List - for use by ClientThread, get the thread list 
-	 * Vector so that a newly spawned thread
-	 * can be run and added to the ThreadList from the ClientThread 
-	 *
-	 * @return	the threadList Vector
-	 */
-	protected Vector getThreadList()
-	{
-		return threadList;
+	void removeThread(DRDAConnThread thread) {
+		threadList.remove(thread);
 	}
 	
 	protected Object getShutdownSync() { return shutdownSync; } 



Mime
View raw message