diff --git a/crates/maelstrom-broker/src/connection.rs b/crates/maelstrom-broker/src/connection.rs index 955ac1e9..547ad605 100644 --- a/crates/maelstrom-broker/src/connection.rs +++ b/crates/maelstrom-broker/src/connection.rs @@ -10,7 +10,7 @@ use maelstrom_base::{ }; use maelstrom_util::{ cache::{fs::std::Fs, TempFileFactory}, - net, + net::{self, AsRawFdExt}, }; use serde::Serialize; use slog::{debug, error, info, o, warn, Logger}; @@ -103,12 +103,19 @@ pub async fn connection_main, temp_file_factory: TempFileFactory, log: Logger, ) { + let mut socket = match socket.set_socket_options() { + Ok(socket) => socket, + Err(err) => { + warn!(log, "error setting socket options"; "error" => %err); + return; + } + }; match net::read_message_from_async_socket(&mut socket, &log).await { Ok(Hello::Client) => { let (read_stream, write_stream) = socket.into_split(); diff --git a/crates/maelstrom-client-process/src/artifact_pusher.rs b/crates/maelstrom-client-process/src/artifact_pusher.rs index 4c008122..1c34eba6 100644 --- a/crates/maelstrom-client-process/src/artifact_pusher.rs +++ b/crates/maelstrom-client-process/src/artifact_pusher.rs @@ -4,7 +4,7 @@ use maelstrom_base::{ proto::{ArtifactPusherToBroker, BrokerToArtifactPusher, Hello}, Sha256Digest, }; -use maelstrom_util::{async_fs::Fs, config::common::BrokerAddr, net}; +use maelstrom_util::{async_fs::Fs, config::common::BrokerAddr, net, net::AsRawFdExt as _}; use slog::Logger; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -32,7 +32,9 @@ async fn push_one_artifact( digest: Sha256Digest, log: &Logger, ) -> Result<()> { - let mut stream = TcpStream::connect(broker_addr.inner()).await?; + let mut stream = TcpStream::connect(broker_addr.inner()) + .await? + .set_socket_options()?; net::write_message_to_async_socket(&mut stream, Hello::ArtifactPusher, log).await?; let fs = Fs::new(); diff --git a/crates/maelstrom-client-process/src/client.rs b/crates/maelstrom-client-process/src/client.rs index cd3a5643..ef64994f 100644 --- a/crates/maelstrom-client-process/src/client.rs +++ b/crates/maelstrom-client-process/src/client.rs @@ -31,7 +31,7 @@ use maelstrom_container::{ use maelstrom_util::{ async_fs, config::common::{BrokerAddr, CacheSize, InlineLimit, Slots}, - net, + net::{self, AsRawFdExt as _}, root::RootBuf, signal, }; @@ -320,6 +320,7 @@ impl Client { TcpStream::connect(broker_addr.inner()) .await .with_context(|| format!("failed to connect to {broker_addr}"))? + .set_socket_options()? .into_split(); debug!(log, "client connected to broker"; "broker_addr" => ?broker_addr);