Skip to content

Commit

Permalink
Fixes #4444 - Connection timeout intermittently when using jetty 9.4.25.
Browse files Browse the repository at this point in the history
Fixed write in doShutdownOutput() by updating the state before the write,
so that needsFillInterest() can check whether to also do a write or not.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Dec 30, 2019
1 parent 5794584 commit d5e962e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
23 changes: 20 additions & 3 deletions jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
Expand Up @@ -1284,9 +1284,26 @@ public void doShutdownOutput()
{
// If we still can't flush, but we are not closing the endpoint,
// let's just flush the encrypted output in the background.
ByteBuffer write = _encryptedOutput;
if (BufferUtil.hasContent(write))
endPoint.write(Callback.from(Callback.NOOP::succeeded, t -> endPoint.close()), write);
ByteBuffer write = null;
synchronized (_decryptedEndPoint)
{
if (BufferUtil.hasContent(_encryptedOutput))
{
write = _encryptedOutput;
_flushState = FlushState.WRITING;
}
}
if (write != null)
{
endPoint.write(Callback.from(() ->
{
synchronized (_decryptedEndPoint)
{
_flushState = FlushState.IDLE;
releaseEncryptedOutputBuffer();
}
}, t -> endPoint.close()), write);
}
}
}

Expand Down
Expand Up @@ -485,9 +485,6 @@ public void testBlockedClose() throws Exception
server.configureBlocking(false);
_manager.accept(server);

//__startBlocking.set(5);
//__blockFor.set(3);

client.getOutputStream().write("Short".getBytes(StandardCharsets.UTF_8));
byte[] buffer = new byte[1024];
int len = client.getInputStream().read(buffer);
Expand Down Expand Up @@ -515,7 +512,7 @@ public void testBlockedClose() throws Exception
assertTrue(__onIncompleteFlush.get());
((TestEP)_lastEndp).getWriteFlusher().completeWrite();
len = client.getInputStream().read(buffer);
assertThat(len, is(len));
assertThat(len, is(-1));
}
}
}
Expand Down

0 comments on commit d5e962e

Please sign in to comment.