8 Commits
Author SHA1 Message Date
Cory Benfield 9b03e08e42 Flush buffered reads when we read a CLOSE_NOTIFY. (#40)
Motivation:

When we read a CLOSE_NOTIFY message, we immediately begin closing the
connection down. This *can* cause an instant close, and if that occurs
then we will have un-flushed data in the read buffer that we never
deliver.

If we receive a CLOSE_NOTIFY we will not receive more application data,
so we should deliver all that application data before we initiate the
shutdown process.

Modifications:

Unbuffer the buffered reads when we read a CLOSE_NOTIFY.

Result:

All reads will be shipped before channelInactive can fire.
2018-09-18 12:39:08 +02:00
Cory Benfield 8d994592e3 Get tests passing with OpenSSL 1.1.1. (#36)
Motivation:

As OpenSSL 1.1.1 has just been released, it is reasonable for users to
be able to use it with SwiftNIO.

Modifications:

- Fixed an issue where we would fail to exclude TLSv1.3 when users set
  max TLS version to lower than TLSv1.3.
- Fixed an issue where we'd fail to read application data sent in the
  same TCP segment as a Finished message.
- Fixed a minor typo in error message strings.

Result:

OpenSSL 1.1.1 is formally supported.
2018-09-17 10:31:55 +01:00
Cory Benfield 9e7e47c1ca Add custom ByteBufferBIO object. (#27)
Motivation:

Currently we use OpenSSL with MemoryBIO objects. These objects are an
implementation of OpenSSL's pervasive BIO abstraction that wrap a simple
heap-allocated buffer.

The result of this is that we have the following data pipeline for
reads:

1. Ciphertext read from the socket into ByteBuffer
2. Ciphertext copied from ByteBuffer to memory BIO
3. Ciphertext copied from memory BIO to transient OpenSSL memory
4. Ciphertext decrypted
5. Plaintext copied from transient OpenSSL memory to ByteBuffer.

And for writes:

1. Plaintext copied from ByteBuffer to transient OpenSSL memory.
2. Plaintext encrypted.
3. Ciphertext copied from transient OpenSSL memory to memory BIO.
4. Plaintext copied from memory BIO to ByteBuffer.
5. Plaintext copied from ByteBuffer to kernel.

The thing is, we don't need all of these copies. Specifically, the
interposing of a memory BIO is totally unnnecessary. We can remove
that copy by implementing the BIO abstraction ourself on top of the
ByteBuffer objects we're using.

This patch does just that.

Modifications:

- Implement a new ByteBufferBIO object.
- Rewrite some core code to use ByteBufferBIO.

Result:

Less memory copying, better efficiency.
2018-08-17 11:52:02 +01:00
Cory Benfield fb3bc221d6 Remove processing of now-nonexistent flush promises. (#6)
Motivation:

There are no more flush promises in NIO, so we don't need to bend
over backwards to track them appropriately.

Modifications:

Remove the code that handles flush promises. Simplify.

Result:

Simpler, easier to follow code for buffered writes.
2018-02-23 11:03:40 +01:00
Johannes Weiss 66863edf2a adopt latest API 2018-02-21 18:56:19 +00:00
Cory Benfield 46b3a8448c Update to newer breaking change of NIO 2018-02-14 09:23:25 +00:00
Cory Benfield 044b978525 Bring up-to-date with NIO latest 2018-02-08 16:50:53 +00:00
Johannes Weiß a6936a36f1 move OpenSSL support from NIO main repo 2018-01-25 18:35:14 +00:00