Skip to content
Snippets Groups Projects

Expire channels that have been unused for too long

Merged yuan requested to merge 0x00A5/arti:issue-41 into main

Expire unused channels based on the discussion in issue #41 (closed) .

Edited by yuan

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Contributor

    @nickm Hi Nick, I have drafted some changes to expire unused channels. Hope I get the idea correctly.

  • requested review from @Diziet

  • Assigning myself as reviewer since I've been discussing this with @0x00A5 over the past while.

  • Nick Mathewson requested review from @nickm and removed review request for @Diziet

    requested review from @nickm and removed review request for @Diziet

  • Nick Mathewson
  • Nick Mathewson
  • Nick Mathewson
  • Nick Mathewson
  • Nick Mathewson
    Nick Mathewson @nickm started a thread on an outdated change in commit 1e80e8e8
  • 168 168 pub(super) fn remove(&mut self, id: CircId) -> Option<CircEnt> {
    169 169 self.m.remove(&id)
    170 170 }
    171
    172 /// Return the total number of open and opening entries in the map
    173 pub(super) fn open_or_opening_ent_count(&self) -> usize {
    • This is an O(n) operation on a structure that used to be O(1) all the time. Maybe we should have the CircMap itself keep track of how many circuits are open-or-opening?

      That could be in a different commit, though. We should just make sure not to forget about it.

    • Author Contributor

      While working on resolving this, I noticed the CircMap::get_mut method.

      pub(super) fn get_mut(&mut self, id: CircId) -> Option<&mut CircEnt>

      I figured to keep track of the open circs counter in all other methods but this one is a bit tricky. I guess one can change an entry from open/opening to destroy-sent (or vice versa) with the mutable reference returned, and the counter will be out of sync.

    • yuan changed this line in version 2 of the diff

      changed this line in version 2 of the diff

    • Yeah: we'll probably need to change or replace this API if we want to have O(1) behavior here.

    • Please register or sign in to reply
  • Nick Mathewson
  • Nick Mathewson
  • Nick Mathewson
  • Nick Mathewson
  • A good start! I've left some comments and suggestions.

  • yuan added 66 commits

    added 66 commits

    Compare with previous version

  • yuan
    yuan @0x00A5 started a thread on the diff
  • 128 129 rsa_id: RsaIdentity,
    129 130 /// If true, this channel is closing.
    130 131 closed: AtomicBool,
    132 /// Since when the channel became unused.
    133 /// If None, this channle is still in use by at lesat one circuit.
    134 unused_since: Mutex<Option<Timestamp>>,
    • Author Contributor

      I think using Mutex to wrap an atomic value might be a bit strange? If I replace the whole Mutex<Option<Timestamp>> with just Timestamp, would it actually be a good idea to use never updated timestamps to represent the still-in-use state of channels?

    • Hm... I think this is possible, but it might require a little work. Here's what I had in mind to get rid of the Mutex.

      I'd define a new OptTimestamp type, based on Timestamp, except with the value 0 representing None. It would behave semantically like Option<Timestamp>, but internally it would just be an AtomicU64. Then I'd give it both update() and clear() functions to change its state, along with the other accessors that the functions update_disused_since and duration_unused would need.

      That's kind of a lot, though. I'm happy to do try this myself post-merge, unless you want to take it on.

    • Please register or sign in to reply
  • yuan added 40 commits

    added 40 commits

    Compare with previous version

  • Nick Mathewson
  • Nick Mathewson
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading