Skip to content

Commit

Permalink
fix #321: Handle the delayed writes when onComplete/onError event is …
Browse files Browse the repository at this point in the history
…sent

When onNext event is sent and the previous thread was not in an event loop then
the write will be delayed. Then when onComplete/onError event is sent, the
implementation need to check the pending writes and also the delayed.
  • Loading branch information
violetagg committed Apr 18, 2018
1 parent 4ce17b6 commit 3e91086
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public void onComplete() {
if (p != 0L) {
produced = 0L;
produced(p);
if (parent.pendingBytes > 0L || parent.hasPendingWriteBytes()) {
if (parent.pendingBytes > 0L || parent.hasPendingWriteBytes() || !lastThreadInEventLoop) {
if (parent.ctx.channel()
.isActive()) {
parent.pendingBytes = 0L;
Expand All @@ -548,7 +548,7 @@ public void onComplete() {
}

if (f != null) {
if (!f.isDone() && parent.hasPendingWriteBytes()) {
if (!f.isDone() && (parent.hasPendingWriteBytes() || !lastThreadInEventLoop)) {
EventLoop eventLoop = parent.ctx.channel().eventLoop();
if (eventLoop.inEventLoop()) {
parent.pendingWriteOffer.test(f, PENDING_WRITES);
Expand Down Expand Up @@ -592,7 +592,7 @@ public void onError(Throwable t) {
}

if (f != null) {
if (!f.isDone() && parent.hasPendingWriteBytes()) {
if (!f.isDone() && (parent.hasPendingWriteBytes() || !lastThreadInEventLoop)) {
EventLoop eventLoop = parent.ctx.channel().eventLoop();
if (eventLoop.inEventLoop()) {
parent.pendingWriteOffer.test(f, PENDING_WRITES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,4 @@ protected void customizeClientOptions(HttpClientOptions.Builder options) {
throw new RuntimeException(e);
}
}

@Override
protected void doTestSendFileAsync(int chunk) throws IOException, URISyntaxException {
// TODO: FIX THIS FOR SSL, remove this overridden method that disables the currently failing tests
// https://github.com/reactor/reactor-netty/issues/321
}
}

0 comments on commit 3e91086

Please sign in to comment.