Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ private class WebSocketOutputStream extends OutputStream {

private static final int WAIT_MILLIS = 10;

private static final int FLUSH_WAIT_MILLIS = 1;

private static final int MAX_FLUSH_ITERATIONS = MAX_WAIT_MILLIS / FLUSH_WAIT_MILLIS;

private final byte stream;

public WebSocketOutputStream(int stream) {
Expand Down Expand Up @@ -272,11 +276,11 @@ public void flush() throws IOException {
int i = 0;
while (WebSocketStreamHandler.this.socket.queueSize() > 0) {
try {
Thread.sleep(100);
Thread.sleep(FLUSH_WAIT_MILLIS);
} catch (InterruptedException ex) {
}
// Wait a maximum of 10 seconds.
if (i++ > 100) {
if (i++ > MAX_FLUSH_ITERATIONS) {
throw new IOException("Timed out waiting for web-socket to flush.");
}
}
Expand Down
Loading