From 9693b97c2147b3fdb9579a1ebb33597cd3bf1d11 Mon Sep 17 00:00:00 2001 From: Boris Schrijver Date: Mon, 21 Sep 2015 16:54:56 +0200 Subject: [PATCH 1/2] Call cleanUp() before looping isStartup(). --- agent/src/com/cloud/agent/Agent.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/agent/src/com/cloud/agent/Agent.java b/agent/src/com/cloud/agent/Agent.java index e3510c41c32..f39d0e78961 100644 --- a/agent/src/com/cloud/agent/Agent.java +++ b/agent/src/com/cloud/agent/Agent.java @@ -394,15 +394,17 @@ public class Agent implements HandlerFactory, IAgentControl { } while (inProgress > 0); _connection.stop(); - while (_connection.isStartup()) { - _shell.getBackoffAlgorithm().waitBeforeRetry(); - } try { _connection.cleanUp(); } catch (final IOException e) { s_logger.warn("Fail to clean up old connection. " + e); } + + while (_connection.isStartup()) { + _shell.getBackoffAlgorithm().waitBeforeRetry(); + } + _connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this); do { s_logger.info("Reconnecting..."); From b34f86c8d55a1cfc057585eab4db0fa2d98a7b3e Mon Sep 17 00:00:00 2001 From: Boris Schrijver Date: Tue, 22 Sep 2015 00:38:16 +0200 Subject: [PATCH 2/2] Added return statement to stop start() if there has been an ConnectException. --- utils/src/main/java/com/cloud/utils/nio/NioConnection.java | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java index ddc84cf18c8..249f512d9c9 100644 --- a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java +++ b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java @@ -88,6 +88,7 @@ public abstract class NioConnection implements Callable { init(); } catch (final ConnectException e) { s_logger.warn("Unable to connect to remote: is there a server running on port " + _port); + return; } catch (final IOException e) { s_logger.error("Unable to initialize the threads.", e); throw new NioConnectionException(e.getMessage(), e);