reduce roomid_mutex_federation
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
22272bdc16
commit
539aa27815
5 changed files with 25 additions and 45 deletions
|
@ -56,7 +56,7 @@ pub struct Service {
|
|||
pub bad_query_ratelimiter: Arc<RwLock<HashMap<OwnedServerName, RateLimitState>>>,
|
||||
pub roomid_mutex_insert: MutexMap<OwnedRoomId, ()>,
|
||||
pub roomid_mutex_state: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>,
|
||||
pub roomid_mutex_federation: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>, // this lock will be held longer
|
||||
pub roomid_mutex_federation: MutexMap<OwnedRoomId, ()>,
|
||||
pub roomid_federationhandletime: RwLock<HashMap<OwnedRoomId, (OwnedEventId, Instant)>>,
|
||||
pub updates_handle: Mutex<Option<JoinHandle<()>>>,
|
||||
pub stateres_mutex: Arc<Mutex<()>>,
|
||||
|
@ -118,7 +118,7 @@ impl Service {
|
|||
bad_query_ratelimiter: Arc::new(RwLock::new(HashMap::new())),
|
||||
roomid_mutex_state: RwLock::new(HashMap::new()),
|
||||
roomid_mutex_insert: MutexMap::<OwnedRoomId, ()>::new(),
|
||||
roomid_mutex_federation: RwLock::new(HashMap::new()),
|
||||
roomid_mutex_federation: MutexMap::<OwnedRoomId, ()>::new(),
|
||||
roomid_federationhandletime: RwLock::new(HashMap::new()),
|
||||
updates_handle: Mutex::new(None),
|
||||
stateres_mutex: Arc::new(Mutex::new(())),
|
||||
|
|
|
@ -1122,16 +1122,11 @@ impl Service {
|
|||
let (event_id, value, room_id) = parse_incoming_pdu(&pdu)?;
|
||||
|
||||
// Lock so we cannot backfill the same pdu twice at the same time
|
||||
let mutex = Arc::clone(
|
||||
services()
|
||||
.globals
|
||||
.roomid_mutex_federation
|
||||
.write()
|
||||
.await
|
||||
.entry(room_id.clone())
|
||||
.or_default(),
|
||||
);
|
||||
let mutex_lock = mutex.lock().await;
|
||||
let mutex_lock = services()
|
||||
.globals
|
||||
.roomid_mutex_federation
|
||||
.lock(&room_id)
|
||||
.await;
|
||||
|
||||
// Skip the PDU if we already have it as a timeline event
|
||||
if let Some(pdu_id) = self.get_pdu_id(&event_id)? {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue