Fixes #4444 - Connection timeout intermittently when using jetty 9.4.25.

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>
This commit is contained in:
Simone Bordet 2019-12-30 17:18:49 +01:00
parent 65c0a76feb
commit 71716d71c4
2 changed files with 21 additions and 7 deletions

View File

@ -1264,9 +1264,26 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr
{
// 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);
}
}
}

View File

@ -484,9 +484,6 @@ public class SslConnectionTest
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);
@ -514,7 +511,7 @@ public class SslConnectionTest
assertTrue(__onIncompleteFlush.get());
((TestEP)_lastEndp).getWriteFlusher().completeWrite();
len = client.getInputStream().read(buffer);
assertThat(len, is(len));
assertThat(len, is(-1));
}
}
}