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 @@ -318,17 +318,27 @@ public void writeFrame(Frame frame) throws IOException {
// we do not wait in the event loop
this.doWriteFrame(frame);
} else {
try {
boolean canWriteNow =
this.handler.writableLatch().await(enqueuingTimeout.toMillis(), MILLISECONDS);
if (canWriteNow) {
this.doWriteFrame(frame);
} else {
this.handler.logEvents();
throw new IOException("Frame enqueuing failed");
// we get the current latch
CountDownLatch latch = this.handler.writableLatch();
if (this.handler.isWritable()) {
// the channel became writable
this.doWriteFrame(frame);
} else {
try {
// the channel is still non-writable
// in case its writability flipped, we have a reference to a latch that has been
// counted down
// so, worst case scenario, we'll enqueue only one frame right away
boolean canWriteNow = latch.await(enqueuingTimeout.toMillis(), MILLISECONDS);
if (canWriteNow) {
this.doWriteFrame(frame);
} else {
this.handler.logEvents();
throw new IOException("Frame enqueuing failed");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
Expand Down