Hacked in mmap default
This commit is contained in:
parent
79a523f2fe
commit
07a5b69a25
4 changed files with 18 additions and 21 deletions
|
|
@ -103,9 +103,9 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
|
||||||
handshake: Handshake<ByteBufOwned>,
|
handshake: Handshake<ByteBufOwned>,
|
||||||
mut conn: tokio::net::TcpStream,
|
mut conn: tokio::net::TcpStream,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if self.addr.ip().to_string() != "213.189.217.38" {
|
// if self.addr.ip().to_string() != "213.189.217.38" {
|
||||||
bail!("DEBUG, NOT MY PEER")
|
// bail!("DEBUG, NOT MY PEER")
|
||||||
}
|
// }
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
|
||||||
let rwtimeout = self
|
let rwtimeout = self
|
||||||
|
|
@ -153,9 +153,9 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
|
||||||
outgoing_chan: tokio::sync::mpsc::UnboundedReceiver<WriterRequest>,
|
outgoing_chan: tokio::sync::mpsc::UnboundedReceiver<WriterRequest>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
if self.addr.ip().to_string() != "213.189.217.38" {
|
// if self.addr.ip().to_string() != "213.189.217.38" {
|
||||||
bail!("DEBUG, NOT MY PEER")
|
// bail!("DEBUG, NOT MY PEER")
|
||||||
}
|
// }
|
||||||
|
|
||||||
let rwtimeout = self
|
let rwtimeout = self
|
||||||
.options
|
.options
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ use crate::{
|
||||||
peer_connection::PeerConnectionOptions,
|
peer_connection::PeerConnectionOptions,
|
||||||
read_buf::ReadBuf,
|
read_buf::ReadBuf,
|
||||||
spawn_utils::BlockingSpawner,
|
spawn_utils::BlockingSpawner,
|
||||||
storage::{filesystem::FilesystemStorageFactory, BoxStorageFactory, StorageFactoryExt},
|
storage::{
|
||||||
|
filesystem::{FilesystemStorageFactory, MmapFilesystemStorageFactory},
|
||||||
|
BoxStorageFactory, StorageFactoryExt,
|
||||||
|
},
|
||||||
torrent_state::{
|
torrent_state::{
|
||||||
ManagedTorrentBuilder, ManagedTorrentHandle, ManagedTorrentState, TorrentStateLive,
|
ManagedTorrentBuilder, ManagedTorrentHandle, ManagedTorrentState, TorrentStateLive,
|
||||||
},
|
},
|
||||||
|
|
@ -190,6 +193,8 @@ pub struct Session {
|
||||||
|
|
||||||
default_defer_writes: bool,
|
default_defer_writes: bool,
|
||||||
|
|
||||||
|
// default_storage_factory: Option<BoxStorageFactory>,
|
||||||
|
|
||||||
// This is stored for all tasks to stop when session is dropped.
|
// This is stored for all tasks to stop when session is dropped.
|
||||||
_cancellation_token_drop_guard: DropGuard,
|
_cancellation_token_drop_guard: DropGuard,
|
||||||
}
|
}
|
||||||
|
|
@ -425,6 +430,7 @@ pub struct SessionOptions {
|
||||||
// If true, will write to disk in separate threads. The downside is additional allocations.
|
// If true, will write to disk in separate threads. The downside is additional allocations.
|
||||||
// May be useful if the disk is slow.
|
// May be useful if the disk is slow.
|
||||||
pub default_defer_writes: bool,
|
pub default_defer_writes: bool,
|
||||||
|
// pub default_storage_factory: Option<BoxStorageFactory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_tcp_listener(
|
async fn create_tcp_listener(
|
||||||
|
|
@ -1017,7 +1023,9 @@ impl Session {
|
||||||
let storage_factory = opts
|
let storage_factory = opts
|
||||||
.storage_factory
|
.storage_factory
|
||||||
.take()
|
.take()
|
||||||
.unwrap_or_else(|| FilesystemStorageFactory::default().boxed());
|
// .unwrap_or_else(|| self.default_storage_factory.clone())
|
||||||
|
// .unwrap_or_else(|| FilesystemStorageFactory::default().boxed());
|
||||||
|
.unwrap_or_else(|| MmapFilesystemStorageFactory::default().boxed());
|
||||||
|
|
||||||
if opts.list_only {
|
if opts.list_only {
|
||||||
return Ok(AddTorrentResponse::ListOnly(ListOnlyResponse {
|
return Ok(AddTorrentResponse::ListOnly(ListOnlyResponse {
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@ mod mmap;
|
||||||
mod opened_file;
|
mod opened_file;
|
||||||
|
|
||||||
pub use fs::{FilesystemStorage, FilesystemStorageFactory};
|
pub use fs::{FilesystemStorage, FilesystemStorageFactory};
|
||||||
|
pub use mmap::{MmapFilesystemStorage, MmapFilesystemStorageFactory};
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,10 @@ use librqbit::{
|
||||||
api::ApiAddTorrentResponse,
|
api::ApiAddTorrentResponse,
|
||||||
http_api::{HttpApi, HttpApiOptions},
|
http_api::{HttpApi, HttpApiOptions},
|
||||||
http_api_client, librqbit_spawn,
|
http_api_client, librqbit_spawn,
|
||||||
<<<<<<< HEAD
|
|
||||||
storage::{
|
storage::{
|
||||||
filesystem::FilesystemStorageFactory,
|
filesystem::{FilesystemStorageFactory, MmapFilesystemStorageFactory},
|
||||||
middleware::{slow::SlowStorageFactory, timing::TimingStorageFactory},
|
|
||||||
StorageFactoryExt,
|
StorageFactoryExt,
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
storage::mmap::MmapStorageFactory,
|
|
||||||
>>>>>>> a557afc (Add --experimental-mmap-storage)
|
|
||||||
tracing_subscriber_config_utils::{init_logging, InitLoggingOptions},
|
tracing_subscriber_config_utils::{init_logging, InitLoggingOptions},
|
||||||
AddTorrent, AddTorrentOptions, AddTorrentResponse, Api, ListOnlyResponse,
|
AddTorrent, AddTorrentOptions, AddTorrentResponse, Api, ListOnlyResponse,
|
||||||
PeerConnectionOptions, Session, SessionOptions, TorrentStatsState,
|
PeerConnectionOptions, Session, SessionOptions, TorrentStatsState,
|
||||||
|
|
@ -401,13 +396,6 @@ async fn async_main(opts: Opts) -> anyhow::Result<()> {
|
||||||
sub_folder: download_opts.sub_folder.clone(),
|
sub_folder: download_opts.sub_folder.clone(),
|
||||||
initial_peers: download_opts.initial_peers.clone().map(|p| p.0),
|
initial_peers: download_opts.initial_peers.clone().map(|p| p.0),
|
||||||
disable_trackers: download_opts.disable_trackers,
|
disable_trackers: download_opts.disable_trackers,
|
||||||
|
|
||||||
storage_factory: Some({
|
|
||||||
let sf = FilesystemStorageFactory::default();
|
|
||||||
let sf = SlowStorageFactory::new(sf);
|
|
||||||
TimingStorageFactory::new("fs".to_owned(), sf).boxed()
|
|
||||||
}),
|
|
||||||
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let connect_to_existing = match client.validate_rqbit_server().await {
|
let connect_to_existing = match client.validate_rqbit_server().await {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue