Skip to content

Commit f38c4e9

Browse files
committed
Bug CS-17825: Don't rely on XS to cleanup idle session but proactively close it from console proxy
1 parent 4fce644 commit f38c4e9

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ public String onAjaxClientStart(String title, List<String> languages, String gue
253253

254254
if(s_logger.isTraceEnabled())
255255
s_logger.trace("Ajax client start, frame buffer w: " + width + ", " + height);
256-
256+
257+
/*
257258
int retry = 0;
258259
tracker.initCoverageTest();
259260
while(!tracker.hasFullCoverage() && retry < 10) {
@@ -263,6 +264,7 @@ public String onAjaxClientStart(String title, List<String> languages, String gue
263264
}
264265
retry++;
265266
}
267+
*/
266268

267269
List<TileInfo> tiles = tracker.scan(true);
268270
String imgUrl = prepareAjaxImage(tiles, true);

services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyGCThread.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private void cleanupLogging() {
6464
public void run() {
6565

6666
boolean bReportLoad = false;
67+
long lastReportTick = System.currentTimeMillis();
6768
while (true) {
6869
cleanupLogging();
6970
bReportLoad = false;
@@ -95,10 +96,12 @@ public void run() {
9596
client.closeClient();
9697
}
9798

98-
if(bReportLoad) {
99+
if(bReportLoad || System.currentTimeMillis() - lastReportTick > 5000) {
99100
// report load changes
100101
String loadInfo = new ConsoleProxyClientStatsCollector(connMap).getStatsReport();
101102
ConsoleProxy.reportLoadInfo(loadInfo);
103+
lastReportTick = System.currentTimeMillis();
104+
102105
if(s_logger.isDebugEnabled())
103106
s_logger.debug("Report load change : " + loadInfo);
104107
}

services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
4646

4747
private VncClient client;
4848
private Thread worker;
49-
private boolean workerDone = false;
49+
private volatile boolean workerDone = false;
5050

5151
private int lastModifierStates = 0;
5252
private int lastPointerMask = 0;
@@ -80,7 +80,7 @@ public void run() {
8080
String tunnelUrl = getClientParam().getClientTunnelUrl();
8181
String tunnelSession = getClientParam().getClientTunnelSession();
8282

83-
for(int i = 0; i < 15; i++) {
83+
for(int i = 0; i < 15 && !workerDone; i++) {
8484
try {
8585
if(tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) {
8686
URI uri = new URI(tunnelUrl);
@@ -136,6 +136,7 @@ public void run() {
136136

137137
@Override
138138
public void closeClient() {
139+
workerDone = true;
139140
if(client != null)
140141
client.shutdown();
141142
}

services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncClientPacketSender.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ public void run() {
7777
s_logger.error("Unexpected exception: ", e);
7878
if (connectionAlive) {
7979
closeConnection();
80-
vncConnection.shutdown();
8180
}
81+
} finally {
82+
s_logger.info("Sending thread exit processing, shutdown connection");
83+
vncConnection.shutdown();
8284
}
8385
}
8486

services/console-proxy/server/src/com/cloud/consoleproxy/vnc/VncServerPacketReceiver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ public void run() {
9090
s_logger.error("Unexpected exception: ", e);
9191
if (connectionAlive) {
9292
closeConnection();
93-
vncConnection.shutdown();
9493
}
94+
} finally {
95+
s_logger.info("Receiving thread exit processing, shutdown connection");
96+
vncConnection.shutdown();
9597
}
9698
}
9799

0 commit comments

Comments
 (0)