Skip to content

Commit

Permalink
fix(client): log socket option errors instead of returning error (hyp…
Browse files Browse the repository at this point in the history
  • Loading branch information
aeryz authored and Benxiang Ge committed Jul 26, 2021
1 parent 98eaa00 commit 7226b70
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ where

let sock = c.connect().await?;

sock.set_nodelay(config.nodelay)
.map_err(ConnectError::m("tcp set_nodelay error"))?;
if let Err(e) = sock.set_nodelay(config.nodelay) {
warn!("tcp set_nodelay error: {}", e);
}

Ok(sock)
}
Expand Down Expand Up @@ -591,9 +592,9 @@ fn connect(
.map_err(ConnectError::m("tcp set_nonblocking error"))?;

if let Some(dur) = config.keep_alive_timeout {
socket
.set_keepalive(Some(dur))
.map_err(ConnectError::m("tcp set_keepalive error"))?;
if let Err(e) = socket.set_keepalive(Some(dur)) {
warn!("tcp set_keepalive error: {}", e);
}
}

bind_local_address(
Expand Down Expand Up @@ -624,21 +625,21 @@ fn connect(
};

if config.reuse_address {
socket
.set_reuseaddr(true)
.map_err(ConnectError::m("tcp set_reuse_address error"))?;
if let Err(e) = socket.set_reuseaddr(true) {
warn!("tcp set_reuse_address error: {}", e);
}
}

if let Some(size) = config.send_buffer_size {
socket
.set_send_buffer_size(size.try_into().unwrap_or(std::u32::MAX))
.map_err(ConnectError::m("tcp set_send_buffer_size error"))?;
if let Err(e) = socket.set_send_buffer_size(size.try_into().unwrap_or(std::u32::MAX)) {
warn!("tcp set_buffer_size error: {}", e);
}
}

if let Some(size) = config.recv_buffer_size {
socket
.set_recv_buffer_size(size.try_into().unwrap_or(std::u32::MAX))
.map_err(ConnectError::m("tcp set_recv_buffer_size error"))?;
if let Err(e) = socket.set_recv_buffer_size(size.try_into().unwrap_or(std::u32::MAX)) {
warn!("tcp set_recv_buffer_size error: {}", e);
}
}

let connect = socket.connect(*addr);
Expand Down

0 comments on commit 7226b70

Please sign in to comment.