Compare commits

...
Author SHA1 Message Date
timedout 716161f2b1 fix: Resolve cherry-pick conflicts 2026-10-16 19:41:36 +01:00
timedout 13e01a6dc9 feat: Always run mutex assertion outside maxperf
Also makes it not a panic
2026-10-16 19:26:30 +01:00
timedout 3ebd068013 perf: Don't hold state lock when unnecessary 2026-10-16 19:26:27 +01:00
29 changed files with 108 additions and 159 deletions

No files matched your search

+2 -3
View File
@@ -849,6 +849,7 @@ impl crate::Context<'_> {
get_room_state::v1::Request::new(at_event_id, room_id.clone()),
)
.await?;
let _state_lock = self.services.rooms.state.mutex.lock(&*room_id).await;
for pdu in remote_state_response.pdus.clone() {
match self
@@ -944,13 +945,11 @@ impl crate::Context<'_> {
.save_state(room_id.clone().as_ref(), new_room_state)
.await?;
let state_lock = self.services.rooms.state.mutex.lock(&*room_id).await;
info!("Forcing new room state");
self.services
.rooms
.state
.force_state(room_id.clone().as_ref(), short_state_hash, added, removed, &state_lock)
.force_state(room_id.clone().as_ref(), short_state_hash, added, removed)
.await?;
info!("Updating joined counts for room");
+2 -10
View File
@@ -773,7 +773,7 @@ impl crate::Context<'_> {
),
&user_id,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await?;
@@ -911,14 +911,6 @@ impl crate::Context<'_> {
);
let redaction_event_id = {
let state_lock = self
.services
.rooms
.state
.mutex
.lock(event.room_id_or_hash().as_str())
.await;
self.services
.rooms
.timeline
@@ -932,7 +924,7 @@ impl crate::Context<'_> {
},
event.sender(),
Some(&event.room_id_or_hash()),
&state_lock,
None,
)
.await?
};
+1 -1
View File
@@ -383,7 +383,7 @@ pub async fn full_user_deactivate(
let _ = services
.rooms
.timeline
.build_and_append_pdu(pdu, user_id, Some(room_id.as_ref()), &state_lock)
.build_and_append_pdu(pdu, user_id, Some(room_id.as_ref()), Some(&state_lock))
.await;
}
+1 -1
View File
@@ -40,7 +40,7 @@ pub(crate) async fn ban_user_route(
),
sender_user,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+2 -2
View File
@@ -177,7 +177,7 @@ async fn send_invite(
PartialPdu::state(recipient_user.to_string(), &content),
sender_user,
Some(room_id),
&state_lock,
Some(&state_lock),
)
.await?;
@@ -276,7 +276,7 @@ async fn send_invite(
PartialPdu::state(recipient_user.to_string(), &content),
sender_user,
Some(room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+1 -1
View File
@@ -48,7 +48,7 @@ pub(crate) async fn kick_user_route(
),
sender_user,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+7 -17
View File
@@ -266,16 +266,9 @@ async fn knock_room_by_id_helper(
.boxed()
.await?;
} else {
knock_room_helper_remote(
services,
sender_user,
room_id,
reason,
servers,
new_state_lock,
)
.boxed()
.await?;
knock_room_helper_remote(services, sender_user, room_id, reason, servers)
.boxed()
.await?;
}
return Ok(knock_room::v3::Response::new(room_id.to_owned()));
@@ -304,7 +297,7 @@ async fn knock_room_by_id_helper(
.boxed()
.await?;
} else {
knock_room_helper_remote(services, sender_user, room_id, reason, servers, state_lock)
knock_room_helper_remote(services, sender_user, room_id, reason, servers)
.boxed()
.await?;
}
@@ -344,7 +337,7 @@ async fn knock_room_helper_local(
PartialPdu::state(sender_user.to_string(), &content),
sender_user,
Some(room_id),
&state_lock,
Some(&state_lock),
)
.await
else {
@@ -465,7 +458,6 @@ async fn knock_room_helper_local(
&parsed_knock_pdu,
knock_event,
once(parsed_knock_pdu.event_id.borrow()),
&state_lock,
room_id,
)
.await?;
@@ -479,7 +471,6 @@ async fn knock_room_helper_remote(
room_id: &RoomId,
reason: Option<String>,
servers: &[OwnedServerName],
state_lock: RoomMutexGuard,
) -> Result {
info!("Knocking {room_id} over federation.");
@@ -641,7 +632,7 @@ async fn knock_room_helper_remote(
services
.rooms
.state
.force_state(room_id, statehash_before_knock, added, removed, &state_lock)
.force_state(room_id, statehash_before_knock, added, removed)
.await?;
let statehash_after_knock = services
@@ -666,7 +657,6 @@ async fn knock_room_helper_remote(
&parsed_knock_pdu,
knock_event,
once(parsed_knock_pdu.event_id.borrow()),
&state_lock,
room_id,
)
.await?;
@@ -677,7 +667,7 @@ async fn knock_room_helper_remote(
services
.rooms
.state
.set_room_state(room_id, statehash_after_knock, &state_lock);
.set_room_state(room_id, statehash_after_knock);
Ok(())
}
+1 -1
View File
@@ -155,7 +155,7 @@ pub async fn leave_room(
PartialPdu::state(user_id.to_string(), &content),
user_id,
Some(room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+1 -1
View File
@@ -47,7 +47,7 @@ pub(crate) async fn unban_user_route(
PartialPdu::state(body.user_id.to_string(), &current_member_content),
sender_user,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+1 -5
View File
@@ -27,8 +27,6 @@ pub(crate) async fn redact_event_route(
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
}
let state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
let event_id = services
.rooms
.timeline
@@ -43,11 +41,9 @@ pub(crate) async fn redact_event_route(
},
sender_user,
Some(&body.room_id),
&state_lock,
None,
)
.await?;
drop(state_lock);
Ok(redact_event::v3::Response::new(event_id))
}
+10 -10
View File
@@ -327,7 +327,7 @@ pub(crate) async fn create_room_route(
},
sender_user,
tmp_id,
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -367,7 +367,7 @@ pub(crate) async fn create_room_route(
PartialPdu::state(sender_user.to_string(), &join_event),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -409,7 +409,7 @@ pub(crate) async fn create_room_route(
},
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -429,7 +429,7 @@ pub(crate) async fn create_room_route(
),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -452,7 +452,7 @@ pub(crate) async fn create_room_route(
),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -468,7 +468,7 @@ pub(crate) async fn create_room_route(
),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -487,7 +487,7 @@ pub(crate) async fn create_room_route(
),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -512,7 +512,7 @@ pub(crate) async fn create_room_route(
services
.rooms
.timeline
.build_and_append_pdu(pdu, sender_user, Some(&room_id), &state_lock)
.build_and_append_pdu(pdu, sender_user, Some(&room_id), Some(&state_lock))
.boxed()
.await?;
}
@@ -567,7 +567,7 @@ pub(crate) async fn create_room_route(
PartialPdu::state(String::new(), &RoomNameEventContent::new(name.clone())),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -581,7 +581,7 @@ pub(crate) async fn create_room_route(
PartialPdu::state(String::new(), &RoomTopicEventContent::new(topic.clone())),
sender_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
+9 -9
View File
@@ -123,7 +123,7 @@ async fn update_parents(
),
sender,
Some(&parent_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await
@@ -218,7 +218,7 @@ async fn update_children(
),
sender,
Some(&child_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await
@@ -246,7 +246,7 @@ async fn update_children(
),
sender,
Some(&child_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await
@@ -324,7 +324,7 @@ pub(crate) async fn upgrade_room_route(
),
sender_user,
Some(&body.room_id),
&old_room_state_lock,
Some(&old_room_state_lock),
)
.await
.map_err(|_| {
@@ -407,7 +407,7 @@ pub(crate) async fn upgrade_room_route(
PartialPdu::state(StateKey::new(), &create_event_content),
sender_user,
replacement_room_id.as_deref(),
&new_room_state_lock,
Some(&new_room_state_lock),
)
.boxed()
.await?;
@@ -453,7 +453,7 @@ pub(crate) async fn upgrade_room_route(
),
sender_user,
replacement_room_id.as_deref(),
&new_room_state_lock,
Some(&new_room_state_lock),
)
.boxed()
.await?;
@@ -527,7 +527,7 @@ pub(crate) async fn upgrade_room_route(
},
sender_user,
replacement_room_id.as_deref(),
&new_room_state_lock,
Some(&new_room_state_lock),
)
.boxed()
.await?;
@@ -572,7 +572,7 @@ pub(crate) async fn upgrade_room_route(
),
sender_user,
Some(&body.room_id),
&old_room_state_lock,
Some(&old_room_state_lock),
)
.await?;
@@ -613,7 +613,7 @@ pub(crate) async fn upgrade_room_route(
),
sender_user,
Some(&body.room_id),
&old_room_state_lock,
Some(&old_room_state_lock),
)
.boxed()
.await
+1 -5
View File
@@ -46,8 +46,6 @@ pub(crate) async fn send_message_event_route(
return Err!(Request(Forbidden("Encryption has been disabled")));
}
let state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
if body.event_type == MessageLikeEventType::CallInvite
&& services.rooms.directory.is_public_room(&body.room_id).await
{
@@ -114,7 +112,7 @@ pub(crate) async fn send_message_event_route(
},
sender_user,
Some(&body.room_id),
&state_lock,
None,
)
.await?;
@@ -125,8 +123,6 @@ pub(crate) async fn send_message_event_route(
event_id.as_bytes(),
);
drop(state_lock);
Ok(send_message_event::v3::Response::new(event_id))
}
+1 -1
View File
@@ -151,7 +151,7 @@ pub(crate) async fn create_join_event_template_route(
),
&body.user_id,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
drop(state_lock);
+1 -1
View File
@@ -107,7 +107,7 @@ pub(crate) async fn create_knock_event_template_route(
),
&body.user_id,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+1 -1
View File
@@ -59,7 +59,7 @@ pub(crate) async fn create_leave_event_template_route(
),
&body.user_id,
Some(&body.room_id),
&state_lock,
Some(&state_lock),
)
.await?;
+9 -9
View File
@@ -75,7 +75,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &create_content),
server_user,
room_id.as_deref(),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -100,7 +100,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -135,7 +135,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &power_levels_content),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -148,7 +148,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &RoomJoinRulesEventContent::new(JoinRule::Invite)),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -164,7 +164,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -180,7 +180,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -194,7 +194,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &RoomNameEventContent::new(room_name)),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -207,7 +207,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &RoomTopicEventContent::markdown(room_topic)),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
@@ -223,7 +223,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
PartialPdu::state(String::new(), &alias_content),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.boxed()
.await?;
+6 -6
View File
@@ -56,7 +56,7 @@ impl super::Service {
),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await?;
@@ -70,7 +70,7 @@ impl super::Service {
),
user_id,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await?;
} else {
@@ -84,7 +84,7 @@ impl super::Service {
),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await?;
}
@@ -116,7 +116,7 @@ impl super::Service {
PartialPdu::state(String::new(), &room_power_levels),
server_user,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await?;
@@ -196,7 +196,7 @@ impl super::Service {
PartialPdu::state(String::new(), &room_power_levels),
self.services.globals.server_user.as_ref(),
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await
.inspect_err(|e| {
@@ -243,7 +243,7 @@ impl super::Service {
PartialPdu::state(user_id.to_string(), &member_content),
self.services.globals.server_user.as_ref(),
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await
.map(|_| ())
+4 -11
View File
@@ -32,7 +32,7 @@ use tokio::sync::RwLock;
use crate::{
Dep, account_data, config, globals,
media::{MXC_LENGTH, mxc::Mxc},
rooms::{self, state::RoomMutexGuard},
rooms,
};
pub struct Service {
@@ -492,7 +492,6 @@ impl Service {
) -> Result<()> {
assert!(self.user_is_admin(user_id).await, "sender is not admin");
let state_lock = self.services.state.mutex.lock(room_id).await;
if let Err(e) = self
.services
.timeline
@@ -500,11 +499,11 @@ impl Service {
PartialPdu::timeline(&self.text_or_file(content).await),
user_id,
Some(room_id),
&state_lock,
None,
)
.await
{
self.handle_response_error(e, room_id, user_id, &state_lock)
self.handle_response_error(e, room_id, user_id)
.boxed()
.await
.unwrap_or_else(default_log);
@@ -518,7 +517,6 @@ impl Service {
e: Error,
room_id: &RoomId,
user_id: &UserId,
state_lock: &RoomMutexGuard,
) -> Result<()> {
error!("Failed to build and append admin room response PDU: \"{e}\"");
let content = RoomMessageEventContent::text_plain(format!(
@@ -528,12 +526,7 @@ impl Service {
self.services
.timeline
.build_and_append_pdu(
PartialPdu::timeline(&content),
user_id,
Some(room_id),
state_lock,
)
.build_and_append_pdu(PartialPdu::timeline(&content), user_id, Some(room_id), None)
.await?;
Ok(())
@@ -325,7 +325,6 @@ impl super::Service {
trace!(%user_id, "user does not have power level to send dummy event, skipping");
continue;
}
let state_lock = self.services.state.mutex.lock(room_id).await;
if self
.services
.timeline
@@ -336,7 +335,7 @@ impl super::Service {
},
&user_id,
Some(room_id),
&state_lock,
None,
)
.await
.inspect(|_| debug!(sender=%user_id, "Successfully sent a dummy event"))
@@ -60,6 +60,14 @@ impl super::Service {
let timer = Instant::now();
let min_depth = self.services.metadata.get_mindepth(room_id).await;
let room_version_rules = get_room_version_rules(create_event)?;
// We lock the room here to prevent the current state from changing
// beneath us mid-check.
let state_lock = if incoming_pdu.state_key.is_some() || incoming_pdu.prev_events.len() > 1
{
Some(self.services.state.mutex.lock(room_id).await)
} else {
None
};
// We now need to resolve the state before the event so that we can
// perform PDU check 5 (event auth passes based on state before the
@@ -81,14 +89,6 @@ impl super::Service {
// that it passes based on the *current* room state (state across all
// forward extremities). If it doesn't, we accept it, but soft-fail
// it, and this prevents it being promoted.
// We lock the room here to prevent the current state from changing
// beneath us mid-check.
trace!(
room_id = %room_id,
"Locking the room"
);
let state_lock = self.services.state.mutex.lock(room_id).await;
let passes_current_state = self
.current_state_check_6(&incoming_pdu, &room_version_rules, create_event)
.await
@@ -175,9 +175,9 @@ impl super::Service {
&room_version_rules,
state_before,
should_soft_fail,
&state_lock,
)
.await?;
drop(state_lock);
if should_soft_fail {
debug_info!(
@@ -193,7 +193,6 @@ impl super::Service {
}
// Event has passed all auth/stateres checks
drop(state_lock);
if incoming_pdu.depth > min_depth && incoming_pdu.state_key().is_some() {
self.services
.metadata
+5 -7
View File
@@ -228,7 +228,7 @@ impl Service {
// If we aren't participating in the room, or failed to join locally,
// try to join over federation.
self.join_remote_room(sender_user, room_id, reason, &servers, &state_lock)
self.join_remote_room(sender_user, room_id, reason, &servers)
.boxed()
.await?;
@@ -291,7 +291,7 @@ impl Service {
PartialPdu::state(sender_user.to_string(), &content),
sender_user,
Some(room_id),
state_lock,
Some(state_lock),
)
.await?;
@@ -305,7 +305,6 @@ impl Service {
room_id: &RoomId,
reason: Option<String>,
servers: &[&OwnedServerName],
state_lock: &RoomMutexGuard,
) -> Result {
// public so the admin command force-join-room-remotely works
info!("Joining {room_id} over federation.");
@@ -664,7 +663,7 @@ impl Service {
debug!("Forcing state for new room");
self.services
.state
.force_state(room_id, statehash_before_join, added, removed, state_lock)
.force_state(room_id, statehash_before_join, added, removed)
.await?;
debug!("Updating joined counts for new room");
@@ -686,7 +685,6 @@ impl Service {
&parsed_join_pdu,
join_event,
once(parsed_join_pdu.event_id.as_ref()),
state_lock,
room_id,
)
.await?;
@@ -701,7 +699,7 @@ impl Service {
// exist
self.services
.state
.set_room_state(room_id, statehash_after_join, state_lock);
.set_room_state(room_id, statehash_after_join);
if !resident_before {
// NOTE: We replace local extremities for this room if we were not a
// resident before. We might be doing a remote join to satisfy
@@ -711,7 +709,7 @@ impl Service {
info!("Replacing local forward extremities");
self.services
.state
.set_forward_extremities(room_id, once(parsed_join_pdu.event_id()), state_lock)
.set_forward_extremities(room_id, once(parsed_join_pdu.event_id()))
.await;
}
drop(cork);
+5 -16
View File
@@ -102,7 +102,6 @@ impl Service {
shortstatehash: u64,
statediffnew: Arc<CompressedState>,
_statediffremoved: Arc<CompressedState>,
state_lock: &RoomMutexGuard,
) -> Result {
let event_ids = statediffnew
.iter()
@@ -139,7 +138,7 @@ impl Service {
self.services.state_cache.update_joined_count(room_id).await;
self.set_room_state(room_id, shortstatehash, state_lock);
self.set_room_state(room_id, shortstatehash);
self.services.sync.wake_all_joined(room_id).await;
@@ -363,14 +362,8 @@ impl Service {
}
/// Set the state hash to a new version, but does not update state_cache.
#[tracing::instrument(skip(self, _mutex_lock), level = "debug")]
pub fn set_room_state(
&self,
room_id: &RoomId,
shortstatehash: u64,
// Take mutex guard to make sure users get the room state mutex
_mutex_lock: &RoomMutexGuard,
) {
#[tracing::instrument(skip(self), level = "debug")]
pub fn set_room_state(&self, room_id: &RoomId, shortstatehash: u64) {
const BUFSIZE: usize = size_of::<u64>();
self.db
@@ -420,12 +413,8 @@ impl Service {
.ignore_err()
}
pub async fn set_forward_extremities<'a, I>(
&'a self,
room_id: &'a RoomId,
event_ids: I,
_state_lock: &'a RoomMutexGuard,
) where
pub async fn set_forward_extremities<'a, I>(&'a self, room_id: &'a RoomId, event_ids: I)
where
I: Iterator<Item = &'a EventId> + Send + 'a,
{
let prefix = (room_id, Interfix);
+1 -1
View File
@@ -146,7 +146,7 @@ impl super::Service {
),
sender,
Some(room_id),
state_lock,
Some(state_lock),
)
.await
.is_ok()
+7 -19
View File
@@ -14,7 +14,6 @@ use conduwuit::{
trace,
utils::{
IterStream, TryFutureExtExt,
mutex_map::Guard,
stream::{BroadbandExt, ReadyExt},
},
warn,
@@ -27,8 +26,8 @@ use conduwuit_core::{
};
use futures::{FutureExt, StreamExt, TryFutureExt, pin_mut};
use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId, OwnedServerName,
RoomId, RoomVersionId, ServerName, UserId,
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedServerName, RoomId,
RoomVersionId, ServerName, UserId,
events::{
AnySyncTimelineEvent, GlobalAccountDataEventType, TimelineEventType,
push_rules::PushRulesEvent,
@@ -43,7 +42,7 @@ use ruma::{
serde::Raw,
};
use super::{ExtractBody, ExtractRelatesTo, ExtractRelatesToEventId, RoomMutexGuard};
use super::{ExtractBody, ExtractRelatesTo, ExtractRelatesToEventId};
use crate::{
appservice::RegistrationInfo,
rooms::state_compressor::{CompressedState, HashSetCompressStateEvent},
@@ -59,7 +58,6 @@ impl super::Service {
room_version_rules: &RoomVersionRules,
state_before: HashMap<u64, OwnedEventId>,
should_soft_fail: bool,
state_lock: &'a RoomMutexGuard,
) -> Result<Option<RawPduId>> {
let room_id = pdu.room_id_or_hash();
@@ -104,18 +102,11 @@ impl super::Service {
.get_forward_extremities(&room_id)
.collect()
.await,
state_lock,
)
.await?;
let pdu_id = self
.append_pdu(
pdu,
pdu_json,
extremities.iter().map(Borrow::borrow),
state_lock,
&room_id,
)
.append_pdu(pdu, pdu_json, extremities.iter().map(Borrow::borrow), &room_id)
.await?;
// Process admin commands for federation events
@@ -166,11 +157,10 @@ impl super::Service {
room_version_rules: &RoomVersionRules,
state_before: HashMap<u64, OwnedEventId>,
current_extremities: Vec<OwnedEventId>,
state_lock: &Guard<OwnedRoomId, ()>,
) -> Result<Vec<OwnedEventId>> {
if incoming_pdu.state_key().is_some() {
debug!("Event is a state-event. Deriving new room state");
self.derive_new_state(incoming_pdu, room_version_rules, state_before, state_lock)
self.derive_new_state(incoming_pdu, room_version_rules, state_before)
.await?;
}
@@ -269,7 +259,6 @@ impl super::Service {
incoming_pdu: &PduEvent,
room_version_rules: &RoomVersionRules,
state_before: HashMap<u64, OwnedEventId>,
state_lock: &Guard<OwnedRoomId, ()>,
) -> Result {
let room_id = incoming_pdu.room_id_or_hash();
// We also add state after incoming event to the fork states
@@ -302,7 +291,7 @@ impl super::Service {
self.services
.state
.force_state(&room_id, shortstatehash, added, removed, state_lock)
.force_state(&room_id, shortstatehash, added, removed)
.await
}
@@ -352,7 +341,6 @@ impl super::Service {
pdu: &'a PduEvent,
mut pdu_json: CanonicalJsonObject,
leaves: Leaves,
state_lock: &'a RoomMutexGuard,
room_id: &'a RoomId,
) -> Result<RawPduId>
where
@@ -387,7 +375,7 @@ impl super::Service {
trace!("setting forward extremities");
self.services
.state
.set_forward_extremities(room_id, leaves, state_lock)
.set_forward_extremities(room_id, leaves)
.await;
let insert_lock = self.mutex_insert.lock(room_id).await;
+2 -5
View File
@@ -30,7 +30,7 @@ impl super::Service {
partial_pdu: PartialPdu,
sender: &UserId,
room_id: Option<&RoomId>,
state_lock: &RoomMutexGuard,
state_lock: Option<&RoomMutexGuard>,
) -> Result<OwnedEventId> {
let (pdu, pdu_json) = self
.create_hash_and_sign_event(partial_pdu, sender, room_id, state_lock)
@@ -134,7 +134,6 @@ impl super::Service {
.iter()
.map(AsRef::as_ref)
.chain(once(pdu.event_id())),
state_lock,
&room_id,
)
.boxed()
@@ -164,9 +163,7 @@ impl super::Service {
// a moment in time where events in the current room state do not
// exist
trace!("Setting room state for room {room_id}");
self.services
.state
.set_room_state(&room_id, statehashid, state_lock);
self.services.state.set_room_state(&room_id, statehashid);
self.services.sync.wake_all_joined(&room_id).await;
+15 -2
View File
@@ -84,7 +84,7 @@ impl super::Service {
partial_pdu: PartialPdu,
sender: &UserId,
room_id: Option<&RoomId>,
_mutex_lock: &RoomMutexGuard,
mutex_lock: Option<&RoomMutexGuard>,
) -> Result<(PduEvent, RoomVersionRules)> {
let PartialPdu {
event_type,
@@ -95,6 +95,19 @@ impl super::Service {
redacts,
timestamp,
} = partial_pdu;
#[cfg(not(feature = "release_max_log_level"))]
if state_key.is_some() && mutex_lock.is_none() {
return Err!(error!(
?event_type,
?content,
?sticky,
?unsigned,
?state_key,
?redacts,
?timestamp,
"Attempted to build a state event without a state mutex lock"
));
}
trace!(
"Creating event of type {} in room {}",
@@ -287,7 +300,7 @@ impl super::Service {
partial_pdu: PartialPdu,
sender: &UserId,
room_id: Option<&RoomId>,
mutex_lock: &RoomMutexGuard,
mutex_lock: Option<&RoomMutexGuard>,
) -> Result<(PduEvent, CanonicalJsonObject)> {
if !self.services.globals.user_is_local(sender) {
return Err!(Request(Forbidden("Sender must be a local user")));
+1 -1
View File
@@ -61,7 +61,7 @@ impl super::Service {
},
sender,
Some(room_id),
state_lock,
Some(state_lock),
)
.await?;
+1 -1
View File
@@ -191,7 +191,7 @@ impl super::Service {
PartialPdu::state(user_id.to_string(), &current_membership),
user_id,
Some(&room_id),
&state_lock,
Some(&state_lock),
)
.await;
}