File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -378,5 +378,25 @@ impl<E> Builder<AddrIncoming, E> {
378
378
self . incoming . set_nodelay ( enabled) ;
379
379
self
380
380
}
381
+
382
+ /// Set whether to sleep on accept errors.
383
+ ///
384
+ /// A possible scenario is that the process has hit the max open files
385
+ /// allowed, and so trying to accept a new connection will fail with
386
+ /// EMFILE. In some cases, it's preferable to just wait for some time, if
387
+ /// the application will likely close some files (or connections), and try
388
+ /// to accept the connection again. If this option is true, the error will
389
+ /// be logged at the error level, since it is still a big deal, and then
390
+ /// the listener will sleep for 1 second.
391
+ ///
392
+ /// In other cases, hitting the max open files should be treat similarly
393
+ /// to being out-of-memory, and simply error (and shutdown). Setting this
394
+ /// option to false will allow that.
395
+ ///
396
+ /// For more details see [`AddrIncoming::set_sleep_on_errors`]
397
+ pub fn tcp_sleep_on_accept_errors ( mut self , val : bool ) -> Self {
398
+ self . incoming . set_sleep_on_errors ( val) ;
399
+ self
400
+ }
381
401
}
382
402
You can’t perform that action at this time.
0 commit comments