Fix blocking_lock panic inside async runtime, reduce pool to 4 connections
spawn_with_arc used blocking_lock() which panics inside tokio runtime. Changed to async lock().await. Reduced StoragePool from 8 to 4 connections for Android compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
43adbbdf7d
commit
7b9edc13da
3 changed files with 7 additions and 7 deletions
|
|
@ -7281,12 +7281,11 @@ pub struct ConnectionActor {
|
|||
impl ConnectionActor {
|
||||
/// Spawn the actor wrapping a shared Arc<Mutex<CM>>, returning a ConnHandle.
|
||||
/// During migration, both the actor and legacy lock-callers share state.
|
||||
pub fn spawn_with_arc(cm: Arc<Mutex<ConnectionManager>>) -> ConnHandle {
|
||||
pub async fn spawn_with_arc(cm: Arc<Mutex<ConnectionManager>>) -> 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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue