Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup on https://github.com/matrix-org/matrix-rust-sdk/pull/3995 #2

Open
wants to merge 14 commits into
base: recovering
Choose a base branch
from

Conversation

Hywan
Copy link

@Hywan Hywan commented Oct 8, 2024

These patch fixes your recovering branch. Once merged, please rebase all the commits, maybe in a single commit as there isn't too much code.

Sorry for the messy commits, but it would be better if I could rebase with your branch 😉.

  • It adds docs
  • It renames the fields
  • It fixes a bug: the Instant is never updated!
  • It fixes another bug: StateMachine::next must not update the state, it must just calculated the next one
  • It improves your new test to reveal these bugs

@@ -127,8 +155,6 @@ impl StateMachine {
}
};

self.set(next_state.clone());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one bug.

@@ -97,9 +122,12 @@ impl StateMachine {
}

Running => {
// We haven't sync for a while so we should go back to recovering
if self.last_sync_date.elapsed() > self.delay_before_recover {
// We haven't changed the state for a while, we go back to `Recovering` to avoid
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not talk about sync but rather about state update here. A sync happens in RoomListService, not here.

pub(super) fn set(&self, state: State) {
self.current.set(state);
let mut last_state_update_time = self.last_state_update_time.lock().unwrap();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one bug fix. Updating the state must reset last_state_update_time.

/// The maximum time before considering the state as “too old”.
///
/// To be used in coordination with `Self::last_state_update_time`.
state_lifespan: Duration,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this naming conveys a better semantics.

Comment on lines +335 to +337
state_machine.set(state_machine.next(sliding_sync).await?);
assert_eq!(state_machine.get(), State::Running);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing we are still in Running reveals one of the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants