Skip to content

Commit 1dfa088

Browse files
committed
fix: limit linger to 5s
1 parent e3fca10 commit 1dfa088

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

crates/rproxy/src/server/metrics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@ impl Metrics {
341341
socket.set_nonblocking(true)?;
342342

343343
// allow time to flush buffers on close
344-
socket.set_linger(Some(Duration::from_secs(1)))?;
344+
socket.set_linger(Some(Duration::from_millis(5000)))?;
345345

346346
// allow binding to the socket while there are still TIME_WAIT connections
347347
socket.set_reuse_address(true)?;
348348

349349
socket.set_tcp_keepalive(
350350
&TcpKeepalive::new()
351-
.with_time(Duration::from_secs(15))
352-
.with_interval(Duration::from_secs(15))
351+
.with_time(Duration::from_millis(15000))
352+
.with_interval(Duration::from_millis(15000))
353353
.with_retries(4),
354354
)?;
355355

crates/rproxy/src/server/proxy/circuit_breaker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl CircuitBreaker {
5151

5252
#[inline]
5353
fn timeout(config: &ConfigCircuitBreaker) -> Duration {
54-
std::cmp::min(Duration::from_secs(5), config.poll_interval * 3 / 4)
54+
std::cmp::min(Duration::from_millis(5000), config.poll_interval * 3 / 4)
5555
}
5656

5757
#[inline]

crates/rproxy/src/server/proxy/http/authrpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ProxyHttpInner<ConfigAuthrpc> for ProxyHttpInnerAuthrpc {
3636
Self {
3737
config,
3838
fcu_cache: Cache::builder()
39-
.time_to_live(Duration::from_secs(60))
39+
.time_to_live(Duration::from_millis(60000))
4040
.max_capacity(4096)
4141
.build_with_hasher(FxBuildHasher),
4242
}

crates/rproxy/src/server/proxy/http/proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ where
311311
socket.set_nonblocking(true)?;
312312

313313
// allow time to flush buffers on close
314-
socket.set_linger(Some(config.backend_timeout()))?;
314+
socket.set_linger(Some(Duration::from_millis(5000)))?;
315315

316316
// allow binding while there are still residual connections in TIME_WAIT
317317
socket.set_reuse_address(true)?;

crates/rproxy/src/server/proxy/ws/proxy.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ where
229229
socket.set_nonblocking(true)?;
230230

231231
// allow time to flush buffers on close
232-
socket.set_linger(Some(config.backend_timeout()))?;
232+
socket.set_linger(Some(Duration::from_millis(5000)))?;
233233

234234
// allow binding to the socket while there are still TIME_WAIT connections
235235
socket.set_reuse_address(true)?;
@@ -686,7 +686,8 @@ where
686686
"Starting websocket pump..."
687687
);
688688

689-
let mut heartbeat = tokio::time::interval(Duration::from_secs(WS_PING_INTERVAL_SECONDS));
689+
let mut heartbeat =
690+
tokio::time::interval(Duration::from_millis(WS_PING_INTERVAL_SECONDS * 1000));
690691

691692
let mut pumping: Result<(), &str> = Ok(());
692693

0 commit comments

Comments
 (0)