| 
     
      
      
      From: <ha...@us...> - 2008-04-03 11:07:14
      
     
   | 
Revision: 1954
          http://cogkit.svn.sourceforge.net/cogkit/?rev=1954&view=rev
Author:   hategan
Date:     2008-04-03 04:07:10 -0700 (Thu, 03 Apr 2008)
Log Message:
-----------
moved connection shutdown outside of the synchronized block
Modified Paths:
--------------
    trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHChannelManager.java
    trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHConnectionBundle.java
Modified: trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHChannelManager.java
===================================================================
--- trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHChannelManager.java	2008-03-26 14:47:59 UTC (rev 1953)
+++ trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHChannelManager.java	2008-04-03 11:07:10 UTC (rev 1954)
@@ -179,9 +179,8 @@
 
         public void run() {
             try {
-                List shutdown = new ArrayList();
+                List shutdownList = new ArrayList();
                 while (true) {
-                    shutdown.clear();
                     Thread.sleep(REAP_INTERVAL);
                     synchronized (bundles) {
                         Iterator i = bundles.entrySet().iterator();
@@ -189,11 +188,21 @@
                             Map.Entry e = (Entry) i.next();
                             ConnectionID ix = (ConnectionID) e.getKey();
                             SSHConnectionBundle bundle = (SSHConnectionBundle) e.getValue();
-                            if (!bundle.shutdownIdleConnections()) {
+                            if (!bundle.shutdownIdleConnections(shutdownList)) {
                                 i.remove();
                             }
                         }
                     }
+                    Iterator i = shutdownList.iterator();
+                    while (i.hasNext()) {
+                        try {
+                            ((Runnable) i.next()).run();
+                        }
+                        catch (Exception e) {
+                            logger.warn("Failed to shut down SSH connection", e);
+                        }
+                    }
+                    shutdownList.clear();
                 }
             }
             catch (InterruptedException e) {
Modified: trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHConnectionBundle.java
===================================================================
--- trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHConnectionBundle.java	2008-03-26 14:47:59 UTC (rev 1953)
+++ trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/SSHConnectionBundle.java	2008-04-03 11:07:10 UTC (rev 1954)
@@ -157,18 +157,22 @@
         }
     }
 
-    public boolean shutdownIdleConnections() {
+    public boolean shutdownIdleConnections(List tasks) {
         long crt = System.currentTimeMillis();
         boolean anyActive = false;
         synchronized (connections) {
             Iterator i = connections.iterator();
             while (i.hasNext()) {
-                Connection c = (Connection) i.next();
+                final Connection c = (Connection) i.next();
                 if (c.sessionCount == 0 && crt - c.idleTime > MAX_IDLE_TIME) {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Shutting down idle connection for " + id);
-                    }
-                    c.ssh.disconnect();
+                    tasks.add(new Runnable() {
+                        public void run() {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("Shutting down idle connection for " + id);
+                            }
+                            c.ssh.disconnect();
+                        }
+                    });
                 }
                 else {
                     anyActive = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |