Fixed CPU usage with Java process, fixed buffering resize issue (manifests as initial blank screen)

This commit is contained in:
Michael Jumper
2010-09-06 17:06:52 -07:00
parent 106df930d6
commit 15a84adf59

View File

@@ -79,13 +79,13 @@ public class GuacamoleClient extends Client {
try { try {
// While we're blocking, or input is available // While we're blocking, or input is available
while (blocking || input.ready()) { do {
// If past threshold, resize buffer before reading // If past threshold, resize buffer before reading
if (usedLength > buffer.length/2) { if (usedLength > buffer.length/2) {
char[] newbuffer = new char[buffer.length*2]; char[] biggerBuffer = new char[buffer.length*2];
System.arraycopy(newbuffer, 0, buffer, 0, usedLength); System.arraycopy(buffer, 0, biggerBuffer, 0, usedLength);
buffer = newbuffer; buffer = biggerBuffer;
} }
// Attempt to fill buffer // Attempt to fill buffer
@@ -122,7 +122,7 @@ public class GuacamoleClient extends Client {
} }
} // End read loop } while (input.ready()); // End read loop
} }
catch (IOException e) { catch (IOException e) {