mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
Set TCP_NODELAY option on TCP sockets (#3055)
This commit is contained in:
parent
d7cbf940c3
commit
4c057a0628
@ -195,6 +195,7 @@ pub async fn connect_tcp<Ws: WithSocket>(
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
let stream = TcpStream::connect((host, port)).await?;
|
||||
stream.set_nodelay(true)?;
|
||||
|
||||
return Ok(with_socket.with_socket(stream));
|
||||
}
|
||||
@ -209,7 +210,13 @@ pub async fn connect_tcp<Ws: WithSocket>(
|
||||
|
||||
// Loop through all the Socket Addresses that the hostname resolves to
|
||||
for socket_addr in (host, port).to_socket_addrs().await? {
|
||||
match Async::<TcpStream>::connect(socket_addr).await {
|
||||
let stream = Async::<TcpStream>::connect(socket_addr)
|
||||
.await
|
||||
.and_then(|s| {
|
||||
s.get_ref().set_nodelay(true)?;
|
||||
Ok(s)
|
||||
});
|
||||
match stream {
|
||||
Ok(stream) => return Ok(with_socket.with_socket(stream)),
|
||||
Err(e) => last_err = Some(e),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user