refactor(service): Use SyncRwLock and SyncMutex for in-memory services

Convert in-memory data structures in appservice, rooms::typing, and sync
wakers to use SyncRwLock and SyncMutex. Drop appservice locks before
making outbound network requests in room alias queries and federation
invites.
This commit is contained in:
Jade Ellis committed 2026-10-28 21:48:22 +00:00
1 parent 5297e01357
commit 24b1e2ebe8
20 files changed
+126 -160

No files matched your search

+2 -4
View File
@@ -20,8 +20,7 @@ pub(crate) async fn create_alias_route(
services
.rooms
.alias
.appservice_checks(&body.room_alias, body.identity.appservice_info())
.await?;
.appservice_checks(&body.room_alias, body.identity.appservice_info())?;
// this isn't apart of alias_checks or delete alias route because we should
// allow removing forbidden room aliases
@@ -69,8 +68,7 @@ pub(crate) async fn delete_alias_route(
services
.rooms
.alias
.appservice_checks(&body.room_alias, body.identity.appservice_info())
.await?;
.appservice_checks(&body.room_alias, body.identity.appservice_info())?;
services
.rooms
+1 -5
View File
@@ -758,11 +758,7 @@ async fn room_alias_check(
if !info.aliases.is_match(full_room_alias.as_str()) {
return Err!(Request(Exclusive("Room alias is not in namespace.")));
}
} else if services
.appservice
.is_exclusive_alias(&full_room_alias)
.await
{
} else if services.appservice.is_exclusive_alias(&full_room_alias) {
return Err!(Request(Exclusive("Room alias reserved by appservice.",)));
}
+1 -1
View File
@@ -201,7 +201,7 @@ pub(crate) async fn sync_events_route(
.update_device_last_seen(sender_user, Some(sender_device), client_ip)
.await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user).await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user);
let response = build_sync_events(&services, &body).await?;
if body.body.full_state
|| !(response.rooms.is_empty()
+1 -1
View File
@@ -147,7 +147,7 @@ pub(crate) async fn sync_events_v5_route(
.sync
.update_snake_sync_request_with_cache(&snake_key, globalsince, &mut body);
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user).await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user);
let mut collection = collect_sync_response(
services,
sender_user,
+1 -1
View File
@@ -64,7 +64,7 @@ pub(crate) async fn continuwuity_local_user_count(
.stream_local_users()
.filter_map(async |user_id| {
if !services.users.status(&user_id).await.is_active()
|| services.appservice.is_exclusive_user_id(&user_id).await
|| services.appservice.is_exclusive_user_id(&user_id)
{
None
} else {