Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client/tls #994

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ openssl-crate = { package = "openssl", version = "0.10", optional = true }
tokio-openssl = { version = "0.6.3", optional = true }

# rustls, http3 and dangerous features shared support
tokio-rustls = { version = "0.25", optional = true }
tokio-rustls = { version = "0.26", optional = true }
webpki-roots = { version = "0.26", optional = true }
rustls-pki-types = "1"

# http3 temporary exclusive
rustls_0dot21 = { package = "rustls", version = "0.21", optional = true }
Expand Down
3 changes: 1 addition & 2 deletions client/src/tls/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ pub(crate) mod openssl {
pub(crate) mod rustls {
use std::sync::Arc;

use rustls_pki_types::ServerName;
use tokio_rustls::{
rustls::{ClientConfig, RootCertStore},
rustls::{pki_types::ServerName, ClientConfig, RootCertStore},
TlsConnector,
};
use webpki_roots::TLS_SERVER_ROOTS;
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Driver {
let tcp = xitca_io::net::io_uring::TcpStream::from_std(std);
io_uring::IoUringDriver::new(
tcp,
drv.rx,
drv.state.take_rx(),
drv.write_buf.into_inner(),
drv.read_buf.into_inner(),
drv.res,
Expand Down
24 changes: 16 additions & 8 deletions postgres/src/driver/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,25 @@
pub(crate) io: Io,
pub(crate) write_buf: WriteBuf,
pub(crate) read_buf: PagedBytesMut,
pub(crate) rx: GenericDriverRx,
pub(crate) state: DriverState,
pub(crate) res: VecDeque<ResponseSender>,
state: DriverState,
}

enum DriverState {
Running,
pub(crate) enum DriverState {
Running(GenericDriverRx),
Closing(Option<io::Error>),
}

impl DriverState {
#[cfg(feature = "io-uring")]
pub(crate) fn take_rx(self) -> GenericDriverRx {

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / clippy

method `take_rx` is never used

warning: method `take_rx` is never used --> postgres/src/driver/generic.rs:44:19 | 42 | impl DriverState { | ---------------- method in this implementation 43 | #[cfg(feature = "io-uring")] 44 | pub(crate) fn take_rx(self) -> GenericDriverRx { | ^^^^^^^ | = note: `#[warn(dead_code)]` on by default

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / other check @ Linux - nightly

method `take_rx` is never used

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / other check @ Linux - nightly

method `take_rx` is never used

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / other check @ Linux - nightly

method `take_rx` is never used

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / other check @ Linux - nightly

method `take_rx` is never used

Check warning on line 44 in postgres/src/driver/generic.rs

View workflow job for this annotation

GitHub Actions / test @ Linux - nightly

method `take_rx` is never used
match self {
Self::Running(rx) => rx,
_ => panic!("driver is closing. no rx can be handed out"),
}
}
}

impl<Io> GenericDriver<Io>
where
Io: AsyncIo,
Expand All @@ -51,9 +60,8 @@
io,
write_buf: WriteBuf::new(),
read_buf: PagedBytesMut::new(),
rx,
res: VecDeque::new(),
state: DriverState::Running,
state: DriverState::Running(rx),
},
tx,
)
Expand All @@ -72,9 +80,9 @@
};

let select = match self.state {
DriverState::Running => {
DriverState::Running(ref mut rx) => {
let ready = self.io.ready(interest);
self.rx.recv().select(ready).await
rx.recv().select(ready).await
}
DriverState::Closing(ref mut e) => {
if !interest.is_writable() && self.res.is_empty() {
Expand Down
14 changes: 7 additions & 7 deletions postgres/src/driver/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mod response;

pub use self::response::Response;

use core::{future::Future, pin::Pin};

use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
use core::{
future::Future,
sync::atomic::{AtomicUsize, Ordering},
};

use std::sync::Arc;

use postgres_protocol::message::backend;
use quinn::{ClientConfig, Connection, Endpoint, ReadError, RecvStream, SendStream};
use quinn_proto::ConnectionError;
Expand Down Expand Up @@ -222,14 +222,14 @@ impl AsyncLendingIterator for QuicDriver {
}

impl Drive for QuicDriver {
fn send(&mut self, msg: BytesMut) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>> {
fn send(&mut self, msg: BytesMut) -> impl Future<Output = Result<(), Error>> + Send {
Box::pin(async move {
self.tx.write_all(&msg).await.unwrap();
Ok(())
})
}

fn recv(&mut self) -> Pin<Box<dyn Future<Output = Result<backend::Message, Error>> + Send + '_>> {
fn recv(&mut self) -> impl Future<Output = Result<backend::Message, Error>> + Send {
Box::pin(async move { self.try_next().await?.ok_or_else(|| Error::from(unexpected_eof_err())) })
}
}
Loading