mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix another "Too many open file open"
Resources need to be released before creating new NioClient instance during the reconnecting.
This commit is contained in:
parent
053246170c
commit
0c1ad8ac88
@ -370,7 +370,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
do {
|
||||
_shell.getBackoffAlgorithm().waitBeforeRetry();
|
||||
|
||||
s_logger.info("Lost connection to the server. Reconnecting....");
|
||||
s_logger.info("Lost connection to the server. Dealing with the remaining commands...");
|
||||
|
||||
inProgress = _inProgress.get();
|
||||
if (inProgress > 0) {
|
||||
@ -379,6 +379,15 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
} while (inProgress > 0);
|
||||
|
||||
_connection.stop();
|
||||
while (_connection.isStartup()){
|
||||
_shell.getBackoffAlgorithm().waitBeforeRetry();
|
||||
}
|
||||
|
||||
try {
|
||||
_connection.cleanUp();
|
||||
} catch (IOException e) {
|
||||
s_logger.warn("Fail to clean up old connection. " + e);
|
||||
}
|
||||
_connection = new NioClient(
|
||||
"Agent",
|
||||
_shell.getHost(),
|
||||
|
||||
@ -175,6 +175,9 @@ public abstract class NioConnection implements Runnable {
|
||||
s_logger.warn("Caught an exception but continuing on.", e);
|
||||
}
|
||||
}
|
||||
synchronized(_thread) {
|
||||
_isStartup = false;
|
||||
}
|
||||
}
|
||||
|
||||
abstract void init() throws IOException;
|
||||
@ -550,6 +553,13 @@ public abstract class NioConnection implements Runnable {
|
||||
_selector.wakeup();
|
||||
}
|
||||
|
||||
/* Release the resource used by the instance */
|
||||
public void cleanUp() throws IOException {
|
||||
if (_selector != null && _selector.isOpen()) {
|
||||
_selector.close();
|
||||
}
|
||||
}
|
||||
|
||||
public class ChangeRequest {
|
||||
public static final int REGISTER = 1;
|
||||
public static final int CHANGEOPS = 2;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user