Updated Branches: refs/heads/master 4fce6448e -> 923deba89
Bug CS-17825: Don't rely on XS to cleanup idle session but proactively close it from console proxy Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f38c4e9e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f38c4e9e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f38c4e9e Branch: refs/heads/master Commit: f38c4e9ea684cdec22491858620072f13f4f0155 Parents: 4fce644 Author: Kelven Yang <kelv...@gmail.com> Authored: Mon Jun 10 17:46:22 2013 -0700 Committer: Kelven Yang <kelv...@gmail.com> Committed: Mon Jun 10 17:46:42 2013 -0700 ---------------------------------------------------------------------- .../src/com/cloud/consoleproxy/ConsoleProxyClientBase.java | 4 +++- .../server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java | 5 ++++- .../src/com/cloud/consoleproxy/ConsoleProxyVncClient.java | 5 +++-- .../src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java | 4 +++- .../src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java | 4 +++- 5 files changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f38c4e9e/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java index f4c912a..07a1b6f 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java @@ -253,7 +253,8 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons if(s_logger.isTraceEnabled()) s_logger.trace("Ajax client start, frame buffer w: " + width + ", " + height); - + +/* int retry = 0; tracker.initCoverageTest(); while(!tracker.hasFullCoverage() && retry < 10) { @@ -263,6 +264,7 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons } retry++; } +*/ List<TileInfo> tiles = tracker.scan(true); String imgUrl = prepareAjaxImage(tiles, true); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f38c4e9e/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java index 7f82a96..9e637a5 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java @@ -64,6 +64,7 @@ public class ConsoleProxyGCThread extends Thread { public void run() { boolean bReportLoad = false; + long lastReportTick = System.currentTimeMillis(); while (true) { cleanupLogging(); bReportLoad = false; @@ -95,10 +96,12 @@ public class ConsoleProxyGCThread extends Thread { client.closeClient(); } - if(bReportLoad) { + if(bReportLoad || System.currentTimeMillis() - lastReportTick > 5000) { // report load changes String loadInfo = new ConsoleProxyClientStatsCollector(connMap).getStatsReport(); ConsoleProxy.reportLoadInfo(loadInfo); + lastReportTick = System.currentTimeMillis(); + if(s_logger.isDebugEnabled()) s_logger.debug("Report load change : " + loadInfo); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f38c4e9e/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java index 6a473b5..5c838a5 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java @@ -46,7 +46,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { private VncClient client; private Thread worker; - private boolean workerDone = false; + private volatile boolean workerDone = false; private int lastModifierStates = 0; private int lastPointerMask = 0; @@ -80,7 +80,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { String tunnelUrl = getClientParam().getClientTunnelUrl(); String tunnelSession = getClientParam().getClientTunnelSession(); - for(int i = 0; i < 15; i++) { + for(int i = 0; i < 15 && !workerDone; i++) { try { if(tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) { URI uri = new URI(tunnelUrl); @@ -136,6 +136,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { @Override public void closeClient() { + workerDone = true; if(client != null) client.shutdown(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f38c4e9e/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java index d27b76d..ea15a60 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java @@ -77,8 +77,10 @@ public class VncClientPacketSender implements Runnable, PaintNotificationListene s_logger.error("Unexpected exception: ", e); if (connectionAlive) { closeConnection(); - vncConnection.shutdown(); } + } finally { + s_logger.info("Sending thread exit processing, shutdown connection"); + vncConnection.shutdown(); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f38c4e9e/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java index 57c8ff8..2bd2c6f 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java @@ -90,8 +90,10 @@ public class VncServerPacketReceiver implements Runnable { s_logger.error("Unexpected exception: ", e); if (connectionAlive) { closeConnection(); - vncConnection.shutdown(); } + } finally { + s_logger.info("Receiving thread exit processing, shutdown connection"); + vncConnection.shutdown(); } }