mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Add support for tcp_user_timeout (#503)
* Add support for tcp_user_timeout * option * duration * Some() * docs * fmt, compile
This commit is contained in:
committed by
GitHub
parent
67579c9af4
commit
3c9565d351
@@ -151,7 +151,13 @@ path: general.tcp_keepalives_interval
|
|||||||
default: 5
|
default: 5
|
||||||
```
|
```
|
||||||
|
|
||||||
Number of seconds between keepalive packets.
|
### tcp_user_timeout
|
||||||
|
```
|
||||||
|
path: general.tcp_user_timeout
|
||||||
|
default: 10000
|
||||||
|
```
|
||||||
|
A linux-only parameters that defines the amount of time in milliseconds that transmitted data may remain unacknowledged or buffered data may remain untransmitted (due to zero window size) before TCP will forcibly disconnect
|
||||||
|
|
||||||
|
|
||||||
### tls_certificate
|
### tls_certificate
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ pub struct General {
|
|||||||
pub tcp_keepalives_count: u32,
|
pub tcp_keepalives_count: u32,
|
||||||
#[serde(default = "General::default_tcp_keepalives_interval")]
|
#[serde(default = "General::default_tcp_keepalives_interval")]
|
||||||
pub tcp_keepalives_interval: u64,
|
pub tcp_keepalives_interval: u64,
|
||||||
|
#[serde(default = "General::default_tcp_user_timeout")]
|
||||||
|
pub tcp_user_timeout: u64,
|
||||||
|
|
||||||
#[serde(default)] // False
|
#[serde(default)] // False
|
||||||
pub log_client_connections: bool,
|
pub log_client_connections: bool,
|
||||||
@@ -360,6 +362,10 @@ impl General {
|
|||||||
5 // 5 seconds
|
5 // 5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_tcp_user_timeout() -> u64 {
|
||||||
|
10000 // 10000 milliseconds
|
||||||
|
}
|
||||||
|
|
||||||
pub fn default_idle_timeout() -> u64 {
|
pub fn default_idle_timeout() -> u64 {
|
||||||
600000 // 10 minutes
|
600000 // 10 minutes
|
||||||
}
|
}
|
||||||
@@ -427,6 +433,7 @@ impl Default for General {
|
|||||||
tcp_keepalives_idle: Self::default_tcp_keepalives_idle(),
|
tcp_keepalives_idle: Self::default_tcp_keepalives_idle(),
|
||||||
tcp_keepalives_count: Self::default_tcp_keepalives_count(),
|
tcp_keepalives_count: Self::default_tcp_keepalives_count(),
|
||||||
tcp_keepalives_interval: Self::default_tcp_keepalives_interval(),
|
tcp_keepalives_interval: Self::default_tcp_keepalives_interval(),
|
||||||
|
tcp_user_timeout: Self::default_tcp_user_timeout(),
|
||||||
log_client_connections: false,
|
log_client_connections: false,
|
||||||
log_client_disconnections: false,
|
log_client_disconnections: false,
|
||||||
autoreload: None,
|
autoreload: None,
|
||||||
|
|||||||
@@ -669,6 +669,13 @@ pub fn configure_socket(stream: &TcpStream) {
|
|||||||
let sock_ref = SockRef::from(stream);
|
let sock_ref = SockRef::from(stream);
|
||||||
let conf = get_config();
|
let conf = get_config();
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
match sock_ref.set_tcp_user_timeout(Some(Duration::from_millis(conf.general.tcp_user_timeout)))
|
||||||
|
{
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(err) => error!("Could not configure tcp_user_timeout for socket: {}", err),
|
||||||
|
}
|
||||||
|
|
||||||
match sock_ref.set_keepalive(true) {
|
match sock_ref.set_keepalive(true) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
match sock_ref.set_tcp_keepalive(
|
match sock_ref.set_tcp_keepalive(
|
||||||
@@ -678,7 +685,7 @@ pub fn configure_socket(stream: &TcpStream) {
|
|||||||
.with_time(Duration::from_secs(conf.general.tcp_keepalives_idle)),
|
.with_time(Duration::from_secs(conf.general.tcp_keepalives_idle)),
|
||||||
) {
|
) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => error!("Could not configure socket: {}", err),
|
Err(err) => error!("Could not configure tcp_keepalive for socket: {}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => error!("Could not configure socket: {}", err),
|
Err(err) => error!("Could not configure socket: {}", err),
|
||||||
|
|||||||
Reference in New Issue
Block a user