Skip to content

Commit f7345e8

Browse files
authored
cpvm: Fix CPVM not releasing CPU after closing console (#7826)
1 parent add64bd commit f7345e8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,34 @@ public void run() {
113113
if (client.isVncOverWebSocketConnectionOpen()) {
114114
updateFrontEndActivityTime();
115115
}
116-
connectionAlive = client.isVncOverWebSocketConnectionAlive();
116+
connectionAlive = session.isOpen();
117117
try {
118118
Thread.sleep(1);
119-
} catch (Exception e) {
120-
s_logger.warn("Error on sleep for vnc over websocket", e);
119+
} catch (InterruptedException e) {
120+
s_logger.error("Error on sleep for vnc over websocket", e);
121121
}
122122
} else if (client.isVncOverNioSocket()) {
123123
byte[] bytesArr;
124124
int nextBytes = client.getNextBytes();
125125
bytesArr = new byte[nextBytes];
126126
client.readBytes(bytesArr, nextBytes);
127+
s_logger.trace(String.format("Read [%s] bytes from client [%s]", nextBytes, clientId));
127128
if (nextBytes > 0) {
128129
session.getRemote().sendBytes(ByteBuffer.wrap(bytesArr));
129130
updateFrontEndActivityTime();
131+
} else {
132+
connectionAlive = session.isOpen();
130133
}
131134
} else {
132135
b = new byte[100];
133136
readBytes = client.read(b);
137+
s_logger.trace(String.format("Read [%s] bytes from client [%s]", readBytes, clientId));
134138
if (readBytes == -1 || (readBytes > 0 && !sendReadBytesToNoVNC(b, readBytes))) {
135139
connectionAlive = false;
136140
}
137141
}
138142
}
139-
connectionAlive = false;
143+
s_logger.info(String.format("Connection with client [%s] is dead.", clientId));
140144
} catch (IOException e) {
141145
s_logger.error("Error on VNC client", e);
142146
}

0 commit comments

Comments
 (0)