@@ -96,6 +96,9 @@ pub enum Host {
96
96
/// omitted or the empty string.
97
97
/// * `connect_timeout` - The time limit in seconds applied to each socket-level connection attempt. Note that hostnames
98
98
/// can resolve to multiple IP addresses, and this limit is applied to each address. Defaults to no timeout.
99
+ /// * `tcp_user_timeout` - The time limit that transmitted data may remain unacknowledged before a connection is forcibly closed.
100
+ /// This is ignored for Unix domain socket connections. It is only supported on systems where TCP_USER_TIMEOUT is available
101
+ /// and will default to the system default; on other systems, it has no effect.
99
102
/// * `keepalives` - Controls the use of TCP keepalive. A value of 0 disables keepalive and nonzero integers enable it.
100
103
/// This option is ignored when connecting with Unix sockets. Defaults to on.
101
104
/// * `keepalives_idle` - The number of seconds of inactivity after which a keepalive message is sent to the server.
@@ -160,7 +163,7 @@ pub struct Config {
160
163
pub ( crate ) host : Vec < Host > ,
161
164
pub ( crate ) port : Vec < u16 > ,
162
165
pub ( crate ) connect_timeout : Option < Duration > ,
163
- pub ( crate ) user_timeout : Option < Duration > ,
166
+ pub ( crate ) tcp_user_timeout : Option < Duration > ,
164
167
pub ( crate ) keepalives : bool ,
165
168
pub ( crate ) keepalive_config : KeepaliveConfig ,
166
169
pub ( crate ) target_session_attrs : TargetSessionAttrs ,
@@ -191,7 +194,7 @@ impl Config {
191
194
host : vec ! [ ] ,
192
195
port : vec ! [ ] ,
193
196
connect_timeout : None ,
194
- user_timeout : None ,
197
+ tcp_user_timeout : None ,
195
198
keepalives : true ,
196
199
keepalive_config,
197
200
target_session_attrs : TargetSessionAttrs :: Any ,
@@ -343,15 +346,19 @@ impl Config {
343
346
}
344
347
345
348
/// Sets the TCP user timeout.
346
- pub fn user_timeout ( & mut self , user_timeout : Duration ) -> & mut Config {
347
- self . user_timeout = Some ( user_timeout) ;
349
+ ///
350
+ /// This is ignored for Unix domain socket connections. It is only supported on systems where
351
+ /// TCP_USER_TIMEOUT is available and will default to the system default; on other systems,
352
+ /// it has no effect.
353
+ pub fn tcp_user_timeout ( & mut self , tcp_user_timeout : Duration ) -> & mut Config {
354
+ self . tcp_user_timeout = Some ( tcp_user_timeout) ;
348
355
self
349
356
}
350
357
351
358
/// Gets the TCP user timeout, if one has been set with the
352
359
/// `user_timeout` method.
353
- pub fn get_user_timeout ( & self ) -> Option < & Duration > {
354
- self . user_timeout . as_ref ( )
360
+ pub fn get_tcp_user_timeout ( & self ) -> Option < & Duration > {
361
+ self . tcp_user_timeout . as_ref ( )
355
362
}
356
363
357
364
/// Controls the use of TCP keepalive.
@@ -488,6 +495,14 @@ impl Config {
488
495
self . connect_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
489
496
}
490
497
}
498
+ "tcp_user_timeout" => {
499
+ let timeout = value
500
+ . parse :: < i64 > ( )
501
+ . map_err ( |_| Error :: config_parse ( Box :: new ( InvalidValue ( "tcp_user_timeout" ) ) ) ) ?;
502
+ if timeout > 0 {
503
+ self . tcp_user_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
504
+ }
505
+ }
491
506
"keepalives" => {
492
507
let keepalives = value
493
508
. parse :: < u64 > ( )
@@ -609,6 +624,7 @@ impl fmt::Debug for Config {
609
624
. field ( "host" , & self . host )
610
625
. field ( "port" , & self . port )
611
626
. field ( "connect_timeout" , & self . connect_timeout )
627
+ . field ( "tcp_user_timeout" , & self . tcp_user_timeout )
612
628
. field ( "keepalives" , & self . keepalives )
613
629
. field ( "keepalives_idle" , & self . keepalive_config . idle )
614
630
. field ( "keepalives_interval" , & self . keepalive_config . interval )
0 commit comments