Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conn: ensure complete_io flushes pending writes.
Previously, calls to `complete_io()` may return as if handshaking has completed, but leave pending TLS writes queued that won't be sent until a subsequent call to `complete_io()` is made. This happens because `is_handshaking()` can begin to return false after calls to `process_new_packets()` while there are final handshake packets put in the connection's buffers, but not yet extracted to be sent to the peer. The end result is that calling `complete_io()` once is not sufficient to fully complete a handshake with a peer. A second call was required to flush the pending packets. In this commit the `complete_io()` logic is updated to continue processing IO when calling `process_new_packets()` has queued TLS writes, only returning to the caller when all pending IO has been dealt with and the handshake truly completed. We can test this behaviour by updating the `client_complete_io_for_handshake` and `server_complete_io_for_handshake` unit tests to assert there are no pending TLS writes after calling `complete_io()`. Prior to this commit these assertions would fail, and with the updated logic they pass as expected.
- Loading branch information