rustls: keep WRITABLE and drain buffered ciphertext when the socket backs up, and bound the plaintext buffer at 256KiB — rustls accepts all plaintext and buffers ciphertext internally on WouldBlock (unlike openssl, which surfaces backpressure through write); expose wants_write()/flush() so the reactor drains it and the sendq caps govern a slow reader. no-op for the openssl and plaintext paths
This commit is contained in:
parent
ebd6e29589
commit
598a019620
3 changed files with 51 additions and 4 deletions
11
src/tls.rs
11
src/tls.rs
|
|
@ -55,6 +55,17 @@ pub trait TlsSession: Send {
|
|||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize>;
|
||||
/// Encrypt+queue application data; returns the plaintext bytes accepted.
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize>;
|
||||
/// Whether the session still holds outbound TLS bytes not yet pushed to the
|
||||
/// socket. rustls buffers ciphertext internally when the socket is full;
|
||||
/// openssl surfaces backpressure through `write`, so it never buffers.
|
||||
fn wants_write(&self) -> bool {
|
||||
false
|
||||
}
|
||||
/// Push any buffered outbound TLS bytes to the socket. `WouldBlock` leaves the
|
||||
/// remainder for the next writable event; a no-op when nothing is buffered.
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
/// The underlying mio socket, for the reactor's poll (re)registration.
|
||||
fn source(&mut self) -> &mut MioStream;
|
||||
/// SHA-256 fingerprint of the peer certificate (CertFP / SASL EXTERNAL), if any.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue