db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r596371 - in /db/derby/code/branches/10.3/java: drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java engine/org/apache/derby/iapi/services/context/ContextService.java
Date Mon, 19 Nov 2007 17:10:48 GMT
Author: kmarsden
Date: Mon Nov 19 09:10:47 2007
New Revision: 596371

URL: http://svn.apache.org/viewvc?rev=596371&view=rev
Log:
DERBY-2564  ContextService.notifyAllActiveThreads() and network server
code need a privileged block around the calls to Thread.interrupt()

merge from trunk rev 595861


Modified:
    db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/context/ContextService.java

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=596371&r1=596370&r2=596371&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Mon Nov 19 09:10:47 2007
@@ -41,6 +41,7 @@
 import javax.net.ssl.SSLServerSocketFactory;
 import java.net.UnknownHostException;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
@@ -704,7 +705,7 @@
 		
 		// We accept clients on a separate thread so we don't run into a problem
 		// blocking on the accept when trying to process a shutdown
-		ClientThread clientThread =	 
+		final ClientThread clientThread =	 
 			(ClientThread) AccessController.doPrivileged(
 								new PrivilegedExceptionAction() {
 									public Object run() throws Exception
@@ -727,13 +728,21 @@
             }
         }
 
-		// Need to interrupt the memcheck thread if it is sleeping.
-		if (mc != null)
-			mc.interrupt();
-
-		//interrupt client thread
-		clientThread.interrupt();
-
+        
+        AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run()  {
+                    // Need to interrupt the memcheck thread if it is sleeping.
+                        if (mc != null)
+                            mc.interrupt();
+
+                        //interrupt client thread
+                        clientThread.interrupt();
+
+                        return null;
+                    }
+                });
+		
  		// Close out the sessions
  		synchronized(sessionTable) {
  			for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
@@ -748,8 +757,16 @@
  			//interupt any connection threads still active
  			for (int i = 0; i < threadList.size(); i++)
  			{
- 				((DRDAConnThread)threadList.get(i)).close();
- 				((DRDAConnThread)threadList.get(i)).interrupt();
+				final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
+                
+ 				threadi.close();
+				AccessController.doPrivileged(
+							new PrivilegedAction() {
+								public Object run() {
+									threadi.interrupt();
+									return null;
+								}
+							});
  			}
  			threadList.clear();
 		}

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java?rev=596371&r1=596370&r2=596371&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
Mon Nov 19 09:10:47 2007
@@ -34,6 +34,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.net.InetAddress;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 
@@ -231,7 +232,13 @@
 			{
 				serverShutdownMethod.invoke( server,
 											 null);
-				serverThread.interrupt();
+				AccessController.doPrivileged(
+							      new PrivilegedAction() {
+								  public Object run() {
+								      serverThread.interrupt();
+								      return null;
+								  }
+							      });				
 				serverThread = null;
 			}
 		   

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/context/ContextService.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/context/ContextService.java?rev=596371&r1=596370&r2=596371&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/context/ContextService.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/services/context/ContextService.java
Mon Nov 19 09:10:47 2007
@@ -25,6 +25,8 @@
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Hashtable;
 import java.util.Enumeration;
 
@@ -556,8 +558,17 @@
 				if (active == null)
 					continue;
 
+                final Thread fActive = active;
 				if (cm.setInterrupted(c))
-					active.interrupt();
+                {
+                    AccessController.doPrivileged(
+                            new PrivilegedAction() {
+                                public Object run()  {
+                                    fActive.interrupt();
+                                    return null;
+                                }
+                            });
+                }
 			}
 		}
 	}



Mime
View raw message