diff --git a/crates/core/src/connection.rs b/crates/core/src/connection.rs index e375b69..b395b99 100644 --- a/crates/core/src/connection.rs +++ b/crates/core/src/connection.rs @@ -7281,12 +7281,11 @@ pub struct ConnectionActor { impl ConnectionActor { /// Spawn the actor wrapping a shared Arc>, returning a ConnHandle. /// During migration, both the actor and legacy lock-callers share state. - pub fn spawn_with_arc(cm: Arc>) -> ConnHandle { + pub async fn spawn_with_arc(cm: Arc>) -> ConnHandle { let (tx, rx) = mpsc::channel(256); // Hoist frequently-needed Arcs so handlers can skip the conn_mgr lock let (storage, blob_store, endpoint, our_node_id, activity_log, is_anchor) = { - // Brief lock just to clone the Arcs - let cm_guard = cm.blocking_lock(); + let cm_guard = cm.lock().await; ( Arc::clone(&cm_guard.storage), Arc::clone(&cm_guard.blob_store), @@ -7302,8 +7301,8 @@ impl ConnectionActor { } /// Spawn the actor owning the ConnectionManager directly (Phase 5+). - pub fn spawn(cm: ConnectionManager) -> ConnHandle { - Self::spawn_with_arc(Arc::new(Mutex::new(cm))) + pub async fn spawn(cm: ConnectionManager) -> ConnHandle { + Self::spawn_with_arc(Arc::new(Mutex::new(cm))).await } async fn run(mut self) { diff --git a/crates/core/src/network.rs b/crates/core/src/network.rs index e36e885..bd8dda2 100644 --- a/crates/core/src/network.rs +++ b/crates/core/src/network.rs @@ -219,7 +219,7 @@ impl Network { let conn_mgr = Arc::new(Mutex::new(conn_mgr)); // Spawn actor wrapping the same Arc> (Phase 1: additive) - let conn_handle = ConnectionActor::spawn_with_arc(Arc::clone(&conn_mgr)); + let conn_handle = ConnectionActor::spawn_with_arc(Arc::clone(&conn_mgr)).await; // TCP UPnP mapping for HTTP post delivery (only if UDP UPnP succeeded) let has_upnp_tcp = if let Some(ref mapping) = upnp_mapping { diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 98df0dc..22895f9 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -37,7 +37,8 @@ pub struct StoragePool { slots: Vec>, } -const STORAGE_POOL_SIZE: usize = 8; +/// Pool size: 4 connections balances parallelism with resource constraints (Android fd limits). +const STORAGE_POOL_SIZE: usize = 4; impl StoragePool { /// Create a pool of Storage connections to the same database.