mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-16 05:36:50 +00:00
chore: Reformat with latest nightly
This commit is contained in:
113 files changed
+981
-831
No files matched your search
@@ -99,8 +99,8 @@ pub fn memory_stats(opts: &str) -> Option<String> {
|
||||
// Acquire the epoch; ensure latest stats are pulled in
|
||||
acq_epoch().ok()?;
|
||||
|
||||
// SAFETY: calls malloc_stats_print() with our string instance which must remain
|
||||
// in this frame. https://docs.rs/tikv-jemalloc-sys/latest/tikv_jemalloc_sys/fn.malloc_stats_print.html
|
||||
// SAFETY: calls malloc_stats_print() with our string instance which must
|
||||
// remain in this frame. https://docs.rs/tikv-jemalloc-sys/latest/tikv_jemalloc_sys/fn.malloc_stats_print.html
|
||||
unsafe { ffi::malloc_stats_print(Some(malloc_stats_cb), opaque, opts_p) };
|
||||
|
||||
str.truncate(MAX_LENGTH);
|
||||
@@ -227,7 +227,8 @@ pub mod this_thread {
|
||||
cell.get_or_init(|| {
|
||||
let ptr: *const u64 = super::get(&mallctl!(name)).expect("failed to obtain pointer");
|
||||
|
||||
// SAFETY: ptr points directly to the internal state of jemalloc for this thread
|
||||
// SAFETY: ptr points directly to the internal state of jemalloc for
|
||||
// this thread
|
||||
unsafe { ptr.as_ref() }.expect("pointer must not be null")
|
||||
})
|
||||
}
|
||||
@@ -291,7 +292,8 @@ pub fn is_phycpu_arena() -> bool { percpu_arenas().is_ok_and(is_equal_to!("phycp
|
||||
|
||||
pub fn percpu_arenas() -> Result<&'static str> {
|
||||
let ptr = get::<*const c_char>(&mallctl!("opt.percpu_arena"))?;
|
||||
//SAFETY: ptr points to a null-terminated string returned for opt.percpu_arena.
|
||||
//SAFETY: ptr points to a null-terminated string returned for
|
||||
// opt.percpu_arena.
|
||||
let cstr = unsafe { CStr::from_ptr(ptr) };
|
||||
cstr.to_str().map_err(Into::into)
|
||||
}
|
||||
@@ -370,8 +372,8 @@ where
|
||||
}
|
||||
|
||||
fn key(name: &str) -> Result<Key> {
|
||||
// tikv asserts the output buffer length is tight to the number of required mibs
|
||||
// so we slice that down here.
|
||||
// tikv asserts the output buffer length is tight to the number of required
|
||||
// mibs so we slice that down here.
|
||||
let segs = name.chars().filter(is_equal_to!(&'.')).count().try_add(1)?;
|
||||
|
||||
let name = self::name(name)?;
|
||||
|
||||
@@ -122,7 +122,8 @@ pub fn check(config: &Config) -> Result {
|
||||
));
|
||||
}
|
||||
|
||||
// yeah, unless the user built a debug build hopefully for local testing only
|
||||
// yeah, unless the user built a debug build hopefully for local testing
|
||||
// only
|
||||
if cfg!(not(debug_assertions)) && config.server_name == "your.server.name" {
|
||||
return Err!(Config(
|
||||
"server_name",
|
||||
|
||||
+19
-17
@@ -47,8 +47,8 @@ impl Manager {
|
||||
let new = Arc::into_raw(config);
|
||||
let old = self.active.swap(new.cast_mut(), Ordering::AcqRel);
|
||||
|
||||
// SAFETY: The old active pointer was set using an Arc::into_raw(). We're
|
||||
// obliged to reconstitute that into Arc otherwise it will leak.
|
||||
// SAFETY: The old active pointer was set using an Arc::into_raw().
|
||||
// We're obliged to reconstitute that into Arc otherwise it will leak.
|
||||
Ok(unsafe { Arc::from_raw(old) })
|
||||
}
|
||||
|
||||
@@ -68,17 +68,18 @@ impl Manager {
|
||||
.as_ref()
|
||||
.expect("handle was already cached for this thread");
|
||||
|
||||
// SAFETY: The caller should not hold multiple references at a time directly
|
||||
// into Config, as a subsequent reference might invalidate the thread's cache
|
||||
// causing another reference to dangle.
|
||||
// SAFETY: The caller should not hold multiple references at a time
|
||||
// directly into Config, as a subsequent reference might invalidate
|
||||
// the thread's cache causing another reference to dangle.
|
||||
//
|
||||
// This is a highly unusual pattern as most config values are copied by value or
|
||||
// used immediately without running overlap with another value. Even if it does
|
||||
// actually occur somewhere, the window of danger is limited to the config being
|
||||
// reloaded while the reference is held and another access is made by the same
|
||||
// thread into a different config value. This is mitigated by creating a buffer
|
||||
// of old configs rather than discarding at the earliest opportunity; the odds
|
||||
// of this scenario are thus astronomical.
|
||||
// This is a highly unusual pattern as most config values are copied by
|
||||
// value or used immediately without running overlap with another
|
||||
// value. Even if it does actually occur somewhere, the window of
|
||||
// danger is limited to the config being reloaded while the reference
|
||||
// is held and another access is made by the same thread into a
|
||||
// different config value. This is mitigated by creating a buffer
|
||||
// of old configs rather than discarding at the earliest opportunity;
|
||||
// the odds of this scenario are thus astronomical.
|
||||
unsafe { std::mem::transmute(config) }
|
||||
}
|
||||
}
|
||||
@@ -87,8 +88,8 @@ impl Drop for Manager {
|
||||
fn drop(&mut self) {
|
||||
let config = self.active.swap(null_mut(), Ordering::AcqRel);
|
||||
|
||||
// SAFETY: The active pointer was set using an Arc::into_raw(). We're obliged to
|
||||
// reconstitute that into Arc otherwise it will leak.
|
||||
// SAFETY: The active pointer was set using an Arc::into_raw(). We're
|
||||
// obliged to reconstitute that into Arc otherwise it will leak.
|
||||
unsafe { Arc::from_raw(config) };
|
||||
}
|
||||
}
|
||||
@@ -119,8 +120,9 @@ fn load_miss(
|
||||
Arc::from_raw(config)
|
||||
};
|
||||
|
||||
// SAFETY: See the note on the transmute above. The caller should not hold more
|
||||
// than one reference at a time directly into Config, as the second access
|
||||
// might invalidate the thread's cache, dangling the reference to the first.
|
||||
// SAFETY: See the note on the transmute above. The caller should not hold
|
||||
// more than one reference at a time directly into Config, as the second
|
||||
// access might invalidate the thread's cache, dangling the reference to
|
||||
// the first.
|
||||
unsafe { std::mem::transmute(handle[index].insert(config)) }
|
||||
}
|
||||
@@ -2862,7 +2862,8 @@ impl Config {
|
||||
.extract::<Self>()
|
||||
.map_err(|e| err!("There was a problem with your configuration file: {e}"))?;
|
||||
|
||||
// don't start if we're listening on both UNIX sockets and TCP at same time
|
||||
// don't start if we're listening on both UNIX sockets and TCP at same
|
||||
// time
|
||||
check::is_dual_listening(raw_config)?;
|
||||
|
||||
Ok(config)
|
||||
|
||||
@@ -221,8 +221,9 @@ impl<E: Event + Clone> TestStore<E> {
|
||||
) -> Result<Vec<OwnedEventId>> {
|
||||
let mut auth_chain_sets = vec![];
|
||||
for ids in event_ids {
|
||||
// TODO state store `auth_event_ids` returns self in the event ids list
|
||||
// when an event returns `auth_event_ids` self is not contained
|
||||
// TODO state store `auth_event_ids` returns self in the event ids
|
||||
// list when an event returns `auth_event_ids` self is not
|
||||
// contained
|
||||
let chain = self
|
||||
.auth_event_ids(room_id, ids)?
|
||||
.into_iter()
|
||||
|
||||
@@ -195,9 +195,11 @@ where
|
||||
"auth_check beginning"
|
||||
);
|
||||
|
||||
// [synapse] check that all the events are in the same room as `incoming_event`
|
||||
// [synapse] check that all the events are in the same room as
|
||||
// `incoming_event`
|
||||
|
||||
// [synapse] do_sig_check check the event has valid signatures for member events
|
||||
// [synapse] do_sig_check check the event has valid signatures for member
|
||||
// events
|
||||
|
||||
let sender = incoming_event.sender();
|
||||
|
||||
@@ -213,7 +215,8 @@ where
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
// If the domain of the room_id does not match the domain of the sender, reject
|
||||
// If the domain of the room_id does not match the domain of the sender,
|
||||
// reject
|
||||
if incoming_event.room_id().is_some() {
|
||||
let Some(room_id_server_name) = incoming_event.room_id().unwrap().server_name()
|
||||
else {
|
||||
@@ -230,7 +233,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// If content.room_version is present and is not a recognized version, reject
|
||||
// If content.room_version is present and is not a recognized version,
|
||||
// reject
|
||||
let content: RoomCreateContentFields = from_json_str(incoming_event.content().get())?;
|
||||
if content
|
||||
.room_version
|
||||
@@ -326,8 +330,8 @@ where
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
// If the create event is referenced in the event's auth events, and this is a
|
||||
// v12 room, reject
|
||||
// If the create event is referenced in the event's auth events, and this is
|
||||
// a v12 room, reject
|
||||
let claims_create_event = incoming_event
|
||||
.auth_events()
|
||||
.any(|id| id == room_create_event.event_id());
|
||||
@@ -335,8 +339,8 @@ where
|
||||
warn!("event incorrectly references m.room.create event in auth events");
|
||||
return Ok(false);
|
||||
} else if !(room_version.room_id_format == RoomIdFormatVersion::V2) && !claims_create_event {
|
||||
// If the create event is not referenced in the event's auth events, and this is
|
||||
// a v11 room, reject
|
||||
// If the create event is not referenced in the event's auth events, and
|
||||
// this is a v11 room, reject
|
||||
warn!(
|
||||
missing = %room_create_event.event_id(),
|
||||
"event incorrectly did not reference an m.room.create in its auth events"
|
||||
@@ -545,9 +549,9 @@ where
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
// If the event type's required power level is greater than the sender's power
|
||||
// level, reject If the event has a state_key that starts with an @ and does
|
||||
// not match the sender, reject.
|
||||
// If the event type's required power level is greater than the sender's
|
||||
// power level, reject If the event has a state_key that starts with an @
|
||||
// and does not match the sender, reject.
|
||||
if !can_send_event(incoming_event, power_levels_event.as_ref(), sender_power_level) {
|
||||
warn!(
|
||||
%sender,
|
||||
@@ -590,13 +594,13 @@ where
|
||||
debug!("m.room.power_levels event allowed");
|
||||
}
|
||||
|
||||
// Room version 3: Redaction events are always accepted (provided the event is
|
||||
// allowed by `events` and `events_default` in the power levels). However,
|
||||
// servers should not apply or send redaction's to clients until both the
|
||||
// redaction event and original event have been seen, and are valid. Servers
|
||||
// should only apply redaction's to events where the sender's domains match, or
|
||||
// the sender of the redaction has the appropriate permissions per the
|
||||
// power levels.
|
||||
// Room version 3: Redaction events are always accepted (provided the event
|
||||
// is allowed by `events` and `events_default` in the power levels).
|
||||
// However, servers should not apply or send redaction's to clients until
|
||||
// both the redaction event and original event have been seen, and are
|
||||
// valid. Servers should only apply redaction's to events where the
|
||||
// sender's domains match, or the sender of the redaction has the
|
||||
// appropriate permissions per the power levels.
|
||||
|
||||
if room_version.authorization.special_case_room_redaction
|
||||
&& *incoming_event.event_type() == TimelineEventType::RoomRedaction
|
||||
@@ -759,8 +763,8 @@ where
|
||||
Ok(match target_membership {
|
||||
| MembershipState::Join => {
|
||||
trace!("starting target_membership=join check");
|
||||
// 1. If the only previous event is an m.room.create and the state_key is the
|
||||
// creator,
|
||||
// 1. If the only previous event is an m.room.create and the
|
||||
// state_key is the creator,
|
||||
// allow
|
||||
let mut prev_events = current_event.prev_events();
|
||||
|
||||
@@ -960,8 +964,8 @@ where
|
||||
},
|
||||
| MembershipState::Leave => {
|
||||
if sender == target_user {
|
||||
// If the sender matches state_key, allow if that user's current membership
|
||||
// state is invite, join, or knock.
|
||||
// If the sender matches state_key, allow if that user's current
|
||||
// membership state is invite, join, or knock.
|
||||
let allow = matches!(
|
||||
target_user_current_membership,
|
||||
MembershipState::Join | MembershipState::Invite | MembershipState::Knock
|
||||
@@ -985,10 +989,11 @@ where
|
||||
);
|
||||
false
|
||||
} else {
|
||||
// If the target user's current membership state is ban, and the sender's power
|
||||
// level is less than the ban level, reject. If the sender's power level is
|
||||
// greater than or equal to the kick level, and the target user's power level is
|
||||
// less than the sender's power level, allow.
|
||||
// If the target user's current membership state is ban, and the
|
||||
// sender's power level is less than the ban level, reject.
|
||||
// If the sender's power level is greater than or equal to
|
||||
// the kick level, and the target user's power level is less
|
||||
// than the sender's power level, allow.
|
||||
let cannot_unban = target_user_current_membership == MembershipState::Ban
|
||||
&& sender_power < effective_power_levels.ban;
|
||||
let can_kick =
|
||||
@@ -1030,9 +1035,9 @@ where
|
||||
);
|
||||
false
|
||||
} else {
|
||||
// If the sender's power level is greater than or equal to the ban level, and
|
||||
// the target user's power level is less than the sender's power level, allow.
|
||||
// Otherwise, reject.
|
||||
// If the sender's power level is greater than or equal to the
|
||||
// ban level, and the target user's power level is less than
|
||||
// the sender's power level, allow. Otherwise, reject.
|
||||
let allow =
|
||||
sender_power >= effective_power_levels.ban && target_power < sender_power;
|
||||
if !allow {
|
||||
@@ -1047,8 +1052,8 @@ where
|
||||
allow
|
||||
},
|
||||
| MembershipState::Knock if room_version.authorization.knocking => {
|
||||
// 1. If the `join_rule` is anything other than `knock` or `knock_restricted`,
|
||||
// reject.
|
||||
// 1. If the `join_rule` is anything other than `knock` or
|
||||
// `knock_restricted`, reject.
|
||||
if !matches!(join_rules, JoinRule::KnockRestricted(_) | JoinRule::Knock) {
|
||||
warn!(
|
||||
"Join rule is not set to knock or knock_restricted, knocking is not allowed"
|
||||
@@ -1057,8 +1062,8 @@ where
|
||||
} else if matches!(join_rules, JoinRule::KnockRestricted(_))
|
||||
&& !room_version.authorization.knock_restricted_join_rule
|
||||
{
|
||||
// 2. If the `join_rule` is `knock_restricted`, but the room does not support
|
||||
// `knock_restricted`, reject.
|
||||
// 2. If the `join_rule` is `knock_restricted`, but the room
|
||||
// does not support `knock_restricted`, reject.
|
||||
warn!(
|
||||
"Join rule is set to knock_restricted but room version does not support \
|
||||
knock_restricted, knocking is not allowed"
|
||||
@@ -1076,8 +1081,8 @@ where
|
||||
sender_membership,
|
||||
MembershipState::Ban | MembershipState::Invite | MembershipState::Join
|
||||
) {
|
||||
// 4. If the `sender`'s current membership is not `ban`, `invite`, or `join`,
|
||||
// allow.
|
||||
// 4. If the `sender`'s current membership is not `ban`,
|
||||
// `invite`, or `join`, allow.
|
||||
// 5. Otherwise, reject.
|
||||
warn!(
|
||||
?target_user_membership_event_id,
|
||||
@@ -1170,16 +1175,17 @@ fn check_power_levels(
|
||||
}
|
||||
|
||||
// - If any of the keys users_default, events_default, state_default, ban,
|
||||
// redact, kick, or invite in content are present and not an integer, reject.
|
||||
// - If either of the keys events or notifications in content are present and
|
||||
// not a dictionary with values that are integers, reject.
|
||||
// - If users key in content is not a dictionary with keys that are valid user
|
||||
// IDs with values that are integers, reject.
|
||||
// redact, kick, or invite in content are present and not an integer,
|
||||
// reject.
|
||||
// - If either of the keys events or notifications in content are present
|
||||
// and not a dictionary with values that are integers, reject.
|
||||
// - If users key in content is not a dictionary with keys that are valid
|
||||
// user IDs with values that are integers, reject.
|
||||
let user_content: RoomPowerLevelsEventContent =
|
||||
deserialize_power_levels(power_event.content().get(), room_version)?;
|
||||
|
||||
// Validation of users is done in Ruma, synapse for loops validating user_ids
|
||||
// and integers here
|
||||
// Validation of users is done in Ruma, synapse for loops validating
|
||||
// user_ids and integers here
|
||||
debug!("validation of power event finished");
|
||||
|
||||
#[allow(clippy::manual_let_else)]
|
||||
@@ -1214,8 +1220,8 @@ fn check_power_levels(
|
||||
let old_state = ¤t_content;
|
||||
let new_state = &user_content;
|
||||
|
||||
// synapse does not have to split up these checks since we can't combine UserIds
|
||||
// and EventTypes we do 2 loops
|
||||
// synapse does not have to split up these checks since we can't combine
|
||||
// UserIds and EventTypes we do 2 loops
|
||||
|
||||
// UserId loop
|
||||
for user in user_levels_to_check {
|
||||
@@ -1229,7 +1235,8 @@ fn check_power_levels(
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the current value is equal to the sender's current power level, reject
|
||||
// If the current value is equal to the sender's current power level,
|
||||
// reject
|
||||
if user != power_event.sender()
|
||||
&& old_level.map(|i| UserPowerLevel::Int(*i)) == Some(user_level)
|
||||
{
|
||||
@@ -1244,8 +1251,9 @@ fn check_power_levels(
|
||||
return Some(false); // cannot remove ops level == to own
|
||||
}
|
||||
|
||||
// If the current value is higher than the sender's current power level, reject
|
||||
// If the new value is higher than the sender's current power level, reject
|
||||
// If the current value is higher than the sender's current power level,
|
||||
// reject If the new value is higher than the sender's current power
|
||||
// level, reject
|
||||
let old_level_too_big = old_level.map(|i| UserPowerLevel::Int(*i)) > Some(user_level);
|
||||
let new_level_too_big = new_level.map(|i| UserPowerLevel::Int(*i)) > Some(user_level);
|
||||
if old_level_too_big {
|
||||
@@ -1280,8 +1288,9 @@ fn check_power_levels(
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the current value is higher than the sender's current power level, reject
|
||||
// If the new value is higher than the sender's current power level, reject
|
||||
// If the current value is higher than the sender's current power level,
|
||||
// reject If the new value is higher than the sender's current power
|
||||
// level, reject
|
||||
let old_level_too_big = old_level.map(|i| UserPowerLevel::Int(*i)) > Some(user_level);
|
||||
let new_level_too_big = new_level.map(|i| UserPowerLevel::Int(*i)) > Some(user_level);
|
||||
if old_level_too_big {
|
||||
@@ -1313,8 +1322,9 @@ fn check_power_levels(
|
||||
let old_level = old_state.notifications.room;
|
||||
let new_level = new_state.notifications.room;
|
||||
if old_level != new_level {
|
||||
// If the current value is higher than the sender's current power level, reject
|
||||
// If the new value is higher than the sender's current power level, reject
|
||||
// If the current value is higher than the sender's current power
|
||||
// level, reject If the new value is higher than the sender's
|
||||
// current power level, reject
|
||||
let old_level_too_big = old_level > user_level;
|
||||
let new_level_too_big = new_level > user_level;
|
||||
if old_level_too_big || new_level_too_big {
|
||||
@@ -1388,8 +1398,8 @@ fn check_redaction(
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
// If the domain of the event_id of the event being redacted is the same as the
|
||||
// domain of the event_id of the m.room.redaction, allow
|
||||
// If the domain of the event_id of the event being redacted is the same as
|
||||
// the domain of the event_id of the m.room.redaction, allow
|
||||
if redaction_event.event_id().server_name()
|
||||
== redaction_event
|
||||
.redacts()
|
||||
|
||||
@@ -142,8 +142,8 @@ where
|
||||
// We used to check that all events are events from the correct room
|
||||
// this is now a check the caller of `resolve` must make.
|
||||
|
||||
// Get only the control events with a state_key: "" or ban/kick event (sender !=
|
||||
// state_key)
|
||||
// Get only the control events with a state_key: "" or ban/kick event
|
||||
// (sender != state_key)
|
||||
let control_events: Vec<_> = all_conflicted
|
||||
.iter()
|
||||
.stream()
|
||||
@@ -187,8 +187,8 @@ where
|
||||
debug!(count = deduped_power_ev.len(), "deduped power events");
|
||||
trace!(set = ?deduped_power_ev, "deduped power events");
|
||||
|
||||
// This removes the control events that passed auth and more importantly those
|
||||
// that failed auth
|
||||
// This removes the control events that passed auth and more importantly
|
||||
// those that failed auth
|
||||
let events_to_resolve: Vec<_> = all_conflicted
|
||||
.iter()
|
||||
.filter(|&id| !deduped_power_ev.contains(id))
|
||||
@@ -490,8 +490,8 @@ where
|
||||
for (node, edges) in graph {
|
||||
if edges.is_empty() {
|
||||
let (power_level, origin_server_ts) = key_fn(node.clone()).await?;
|
||||
// The `Reverse` is because rusts `BinaryHeap` sorts largest -> smallest we need
|
||||
// smallest -> largest
|
||||
// The `Reverse` is because rusts `BinaryHeap` sorts largest ->
|
||||
// smallest we need smallest -> largest
|
||||
zero_outdegree.push(Reverse(TieBreaker {
|
||||
power_level,
|
||||
origin_server_ts,
|
||||
@@ -507,7 +507,8 @@ where
|
||||
|
||||
let mut heap = BinaryHeap::from(zero_outdegree);
|
||||
|
||||
// We remove the oldest node (most incoming edges) and check against all other
|
||||
// We remove the oldest node (most incoming edges) and check against all
|
||||
// other
|
||||
let mut sorted = vec![];
|
||||
// Destructure the `Reverse` and take the smallest `node` each time
|
||||
while let Some(Reverse(item)) = heap.pop() {
|
||||
@@ -574,8 +575,8 @@ where
|
||||
let sender_is_creator =
|
||||
sender_is_creator(&event, room_version, &auth_events, fetch_event).await?;
|
||||
|
||||
// Since v12 the room creators outrank any m.room.power_levels event, so their
|
||||
// ordering position does not depend on one being in scope.
|
||||
// Since v12 the room creators outrank any m.room.power_levels event, so
|
||||
// their ordering position does not depend on one being in scope.
|
||||
if sender_is_creator
|
||||
&& room_version
|
||||
.authorization
|
||||
@@ -628,8 +629,8 @@ where
|
||||
.find(|aev| is_type_and_key(*aev, &TimelineEventType::RoomCreate, ""))
|
||||
.cloned();
|
||||
|
||||
// Since v12 the create event is no longer listed in auth_events; the room ID
|
||||
// is its event ID.
|
||||
// Since v12 the create event is no longer listed in auth_events; the room
|
||||
// ID is its event ID.
|
||||
let create_event = match create_event {
|
||||
| Some(create_event) => Some(create_event),
|
||||
| None =>
|
||||
@@ -738,10 +739,11 @@ where
|
||||
trace!(map = ?auth_events.keys().collect::<Vec<_>>(), "fetched auth events");
|
||||
|
||||
let auth_events = &auth_events;
|
||||
// NOTE: in state resolution v2.1, auth checks should start with an empty state
|
||||
// map. It is the caller's job to do this. Previously, this function would
|
||||
// force an empty state map in this case, and this resulted in power events
|
||||
// going missing from the resolved state as they'd be discarded here.
|
||||
// NOTE: in state resolution v2.1, auth checks should start with an empty
|
||||
// state map. It is the caller's job to do this. Previously, this function
|
||||
// would force an empty state map in this case, and this resulted in power
|
||||
// events going missing from the resolved state as they'd be discarded
|
||||
// here.
|
||||
let mut resolved_state = unconflicted_state;
|
||||
for event in events_to_check {
|
||||
trace!(event_id = event.event_id().as_str(), "checking event");
|
||||
@@ -774,8 +776,8 @@ where
|
||||
}
|
||||
for aid in event.auth_events() {
|
||||
if let Some(ev) = auth_events.get(aid) {
|
||||
//TODO: synapse checks "rejected_reason" which is most likely related to
|
||||
// soft-failing
|
||||
//TODO: synapse checks "rejected_reason" which is most likely
|
||||
// related to soft-failing
|
||||
trace!(event_id = aid.as_str(), "found auth event");
|
||||
auth_state.insert(
|
||||
ev.event_type()
|
||||
@@ -809,8 +811,8 @@ where
|
||||
|
||||
debug!(event_id = event.event_id().as_str(), "Running auth checks");
|
||||
|
||||
// The key for this is (eventType + a state_key of the signed token not sender)
|
||||
// so search for it
|
||||
// The key for this is (eventType + a state_key of the signed token not
|
||||
// sender) so search for it
|
||||
let current_third_party = auth_state.iter().find_map(|(_, pdu)| {
|
||||
(*pdu.event_type() == TimelineEventType::RoomThirdPartyInvite).then_some(pdu)
|
||||
});
|
||||
@@ -848,7 +850,8 @@ where
|
||||
trace!(map = ?resolved_state, "new resolved state");
|
||||
},
|
||||
| Ok(false) => {
|
||||
// synapse passes here on AuthError. We do not add this event to resolved_state.
|
||||
// synapse passes here on AuthError. We do not add this event to
|
||||
// resolved_state.
|
||||
warn!("event {} failed the authentication check", event.event_id());
|
||||
},
|
||||
| Err(e) => {
|
||||
@@ -1276,8 +1279,8 @@ mod tests {
|
||||
// #[tokio::test]
|
||||
async fn test_sort() {
|
||||
for _ in 0..20 {
|
||||
// since we shuffle the eventIds before we sort them introducing randomness
|
||||
// seems like we should test this a few times
|
||||
// since we shuffle the eventIds before we sort them introducing
|
||||
// randomness seems like we should test this a few times
|
||||
test_event_sort().await;
|
||||
}
|
||||
}
|
||||
@@ -1917,7 +1920,8 @@ mod tests {
|
||||
.iter(),
|
||||
);
|
||||
|
||||
// HashMap iteration order is random, so sort this before asserting on it
|
||||
// HashMap iteration order is random, so sort this before asserting on
|
||||
// it
|
||||
for v in conflicted.values_mut() {
|
||||
v.sort_unstable();
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ pub(crate) async fn do_check(
|
||||
// event_id -> StateMap<OwnedEventId>
|
||||
let mut state_at_event: HashMap<OwnedEventId, StateMap<OwnedEventId>> = HashMap::new();
|
||||
|
||||
// Resolve the current state and add it to the state_at_event map then continue
|
||||
// on in "time"
|
||||
// Resolve the current state and add it to the state_at_event map then
|
||||
// continue on in "time"
|
||||
for node in super::lexicographical_topological_sort(&graph, &|_id| async {
|
||||
Ok((int!(0), MilliSecondsSinceUnixEpoch(uint!(0))))
|
||||
})
|
||||
@@ -172,8 +172,9 @@ pub(crate) async fn do_check(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO The event is just remade, adding the auth_events and prev_events here
|
||||
// the `to_pdu_event` was split into `init` and the fn below, could be better
|
||||
// TODO The event is just remade, adding the auth_events and prev_events
|
||||
// here the `to_pdu_event` was split into `init` and the fn below,
|
||||
// could be better
|
||||
let e = fake_event;
|
||||
let ev_id = e.event_id();
|
||||
let event = to_pdu_event(
|
||||
|
||||
@@ -45,8 +45,8 @@ impl Module {
|
||||
.as_ref()
|
||||
.expect("backing library loaded by this instance");
|
||||
|
||||
// SAFETY: Calls dlsym(3) on unix platforms. This might not have to be unsafe
|
||||
// if wrapped in libloading with_dlerror().
|
||||
// SAFETY: Calls dlsym(3) on unix platforms. This might not have to be
|
||||
// unsafe if wrapped in libloading with_dlerror().
|
||||
let sym = unsafe { handle.get::<Prototype>(cname.as_bytes()) };
|
||||
let sym = sym.expect("symbol found; binding successful");
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ pub fn from_name(name: &str) -> Result<Library> {
|
||||
}
|
||||
|
||||
pub fn from_path(path: &OsStr) -> Result<Library> {
|
||||
//SAFETY: Calls dlopen(3) on unix platforms. This might not have to be unsafe
|
||||
// if wrapped in with_dlerror.
|
||||
//SAFETY: Calls dlopen(3) on unix platforms. This might not have to be
|
||||
// unsafe if wrapped in with_dlerror.
|
||||
let lib = unsafe { Library::open(Some(path), OPEN_FLAGS) };
|
||||
if let Err(e) = lib {
|
||||
let name = path::to_name(path)?;
|
||||
|
||||
@@ -27,8 +27,8 @@ impl fmt::Display for Escape<'_> {
|
||||
fmt.write_str(&pile_o_bits[last..i])?;
|
||||
fmt.write_str(s)?;
|
||||
|
||||
// NOTE: we only expect single byte characters here - which is fine as long as
|
||||
// we only match single byte characters
|
||||
// NOTE: we only expect single byte characters here - which is fine
|
||||
// as long as we only match single byte characters
|
||||
last = i.saturating_add(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ impl<'a> From<&'a str> for &'a Unquoted {
|
||||
fn from(s: &'a str) -> &'a Unquoted {
|
||||
let s: &'a str = s.unquote_infallible();
|
||||
|
||||
//SAFETY: This is a pattern I lifted from ruma-identifiers for strong-type strs
|
||||
// by wrapping in a tuple-struct.
|
||||
//SAFETY: This is a pattern I lifted from ruma-identifiers for
|
||||
// strong-type strs by wrapping in a tuple-struct.
|
||||
#[allow(clippy::transmute_ptr_to_ptr)]
|
||||
unsafe {
|
||||
std::mem::transmute(s)
|
||||
|
||||
@@ -120,10 +120,11 @@ pub fn cores_available() -> impl Iterator<Item = Id> { from_mask(*CORES_AVAILABL
|
||||
pub fn getcpu() -> Result<usize> {
|
||||
use crate::{Error, utils::math};
|
||||
|
||||
// SAFETY: This is part of an interface with many low-level calls taking many
|
||||
// raw params, but it's unclear why this specific call is unsafe. Nevertheless
|
||||
// the value obtained here is semantically unsafe because it can change on the
|
||||
// instruction boundary trailing its own acquisition and also any other time.
|
||||
// SAFETY: This is part of an interface with many low-level calls taking
|
||||
// many raw params, but it's unclear why this specific call is unsafe.
|
||||
// Nevertheless the value obtained here is semantically unsafe because it
|
||||
// can change on the instruction boundary trailing its own acquisition and
|
||||
// also any other time.
|
||||
let ret: i32 = unsafe { libc::sched_getcpu() };
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
||||
Reference in new issue
Block a user