Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set TCP_NODELAY option on TCP sockets (launchbadge#3055)
Browse files Browse the repository at this point in the history
mirek26 authored and kukabi committed Feb 22, 2024

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
1 parent 6e2dd84 commit af01a1e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sqlx-core/src/net/socket/mod.rs
Original file line number Diff line number Diff line change
@@ -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),
}

0 comments on commit af01a1e

Please sign in to comment.