cleanup on drop for utils::mutex_map.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-09 20:04:43 +00:00
parent 01b2928d55
commit 2d251eb19c
10 changed files with 131 additions and 54 deletions

View file

@ -3,7 +3,8 @@ use std::{collections::HashSet, sync::Arc};
use conduit::{utils, Error, Result};
use database::{Database, Map};
use ruma::{EventId, OwnedEventId, RoomId};
use utils::mutex_map;
use crate::globals::RoomMutexGuard;
pub(super) struct Data {
shorteventid_shortstatehash: Arc<Map>,
@ -35,7 +36,7 @@ impl Data {
&self,
room_id: &RoomId,
new_shortstatehash: u64,
_mutex_lock: &mutex_map::Guard<()>, // Take mutex guard to make sure users get the room state mutex
_mutex_lock: &RoomMutexGuard, // Take mutex guard to make sure users get the room state mutex
) -> Result<()> {
self.roomid_shortstatehash
.insert(room_id.as_bytes(), &new_shortstatehash.to_be_bytes())?;
@ -68,7 +69,7 @@ impl Data {
&self,
room_id: &RoomId,
event_ids: Vec<OwnedEventId>,
_mutex_lock: &mutex_map::Guard<()>, // Take mutex guard to make sure users get the room state mutex
_mutex_lock: &RoomMutexGuard, // Take mutex guard to make sure users get the room state mutex
) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xFF);