You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2015/04/15 17:43:45 UTC

git commit: updated refs/heads/4.5 to fde2615

Repository: cloudstack
Updated Branches:
  refs/heads/4.5 cb7bcf23f -> fde2615c3


CLOUDSTACK-8387 - Close mgmt server peer socket on failure, without relying on autoclose


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fde2615c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fde2615c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fde2615c

Branch: refs/heads/4.5
Commit: fde2615c33106306f45387ec14c1fff587e478d4
Parents: cb7bcf2
Author: MS <m...@turboio.com>
Authored: Wed Apr 15 08:43:02 2015 -0700
Committer: Marcus Sorensen <ma...@apple.com>
Committed: Wed Apr 15 08:43:37 2015 -0700

----------------------------------------------------------------------
 .../com/cloud/agent/manager/ClusteredAgentManagerImpl.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fde2615c/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 2417f4d..d218cf4 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -498,8 +498,9 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
                 } catch (UnknownHostException e) {
                     throw new CloudRuntimeException("Unable to resolve " + ip);
                 }
+                SocketChannel ch1;
                 try {
-                    SocketChannel ch1 = SocketChannel.open(new InetSocketAddress(addr, Port.value()));
+                    ch1 = SocketChannel.open(new InetSocketAddress(addr, Port.value()));
                     ch1.configureBlocking(true); // make sure we are working at blocking mode
                     ch1.socket().setKeepAlive(true);
                     ch1.socket().setSoTimeout(60 * 1000);
@@ -512,6 +513,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
                         Link.doHandshake(ch1, sslEngine, true);
                         s_logger.info("SSL: Handshake done");
                     } catch (Exception e) {
+                        ch1.close();
                         throw new IOException("SSL: Fail to init SSL! " + e);
                     }
                     if (s_logger.isDebugEnabled()) {
@@ -521,6 +523,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
                     _sslEngines.put(peerName, sslEngine);
                     return ch1;
                 } catch (IOException e) {
+                    try {
+                        ch1.close();
+                    } catch (IOException ex) {
+                        s_logger.error("failed to close failed peer socket: " + ex);
+                    }
                     s_logger.warn("Unable to connect to peer management server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e);
                     return null;
                 }