Add read/write timeouts and avoid stuck peers
This commit is contained in:
parent
ae847ce99c
commit
9e8f235cb4
5 changed files with 59 additions and 55 deletions
|
|
@ -32,6 +32,7 @@ use crate::{
|
|||
struct TorrentManagerOptions {
|
||||
force_tracker_interval: Option<Duration>,
|
||||
peer_connect_timeout: Option<Duration>,
|
||||
peer_read_write_timeout: Option<Duration>,
|
||||
only_files: Option<Vec<usize>>,
|
||||
peer_id: Option<Id20>,
|
||||
overwrite: bool,
|
||||
|
|
@ -90,6 +91,11 @@ impl TorrentManagerBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn peer_read_write_timeout(&mut self, timeout: Duration) -> &mut Self {
|
||||
self.options.peer_read_write_timeout = Some(timeout);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn start_manager(self) -> anyhow::Result<TorrentManagerHandle> {
|
||||
TorrentManager::start(
|
||||
self.info,
|
||||
|
|
@ -256,6 +262,7 @@ impl TorrentManager {
|
|||
#[allow(clippy::needless_update)]
|
||||
let state_options = TorrentStateOptions {
|
||||
peer_connect_timeout: options.peer_connect_timeout,
|
||||
peer_read_write_timeout: options.peer_read_write_timeout,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue