mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Fix race condition where tunnel is detached before client has chance to retrieve error message in header via second request.
This commit is contained in:
@@ -187,9 +187,16 @@ public abstract class GuacamoleTunnelServlet extends HttpServlet {
|
||||
|
||||
Writer out = response.getWriter();
|
||||
|
||||
// Detach tunnel and throw error if EOF (and we haven't sent any
|
||||
// data yet.
|
||||
char[] message = reader.read();
|
||||
if (message == null) {
|
||||
session.detachTunnel(tunnel);
|
||||
throw new GuacamoleException("Disconnected.");
|
||||
}
|
||||
|
||||
// For all messages, until another stream is ready (we send at least one message)
|
||||
char[] message;
|
||||
while ((message = reader.read()) != null) {
|
||||
do {
|
||||
|
||||
// Get message output bytes
|
||||
out.write(message, 0, message.length);
|
||||
@@ -200,12 +207,7 @@ public abstract class GuacamoleTunnelServlet extends HttpServlet {
|
||||
if (tunnel.hasQueuedReaderThreads())
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (message == null) {
|
||||
session.detachTunnel(tunnel);
|
||||
throw new GuacamoleException("Disconnected.");
|
||||
}
|
||||
} while ((message = reader.read()) != null);
|
||||
|
||||
// End-of-instructions marker
|
||||
out.write(';');
|
||||
|
Reference in New Issue
Block a user