Channel drops were not checking whether forks done in the same transaction before dropping unused patches

pmeunier
Dec 5, 2021, 6:45 PM
L5JW24DB46ZJDJBOMFULVJRMUBF67LG2NP2GWLLBVYC524CYV5LQC

Dependencies

  • [2] G6YXRFH2 Channel drop with tags
  • [3] RRCSHAYZ Formatting
  • [4] VSOT2QH5 Fixing channel drop (cleanup in other tables + order of reference drop)
  • [5] TZ42DX3B Properly dropping a channel
  • [6] NGCTMCDP cleaning up the deps and revdeps of unused changes after a channel drop
  • [*] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).

Change contents

  • edit in libpijul/src/pristine/sanakirja.rs at line 1918
    [4.169]
    [4.169]
    debug!(target: "drop_channel", "drop channel {:?}", name0);
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1953
    [4.151][4.151:285]()
    for chan in self.iter_channels("").map_err(|e| e.0)? {
    let (name, chan) = chan.map_err(|e| e.0)?;
    [4.151]
    [2.136]
    debug!(target: "drop_channel", "testing unused change: {:?}", p);
    let mut it0 = self.iter_channels("").map_err(|e| e.0)?;
    let it1 = self.open_channels.lock();
    let mut it1 = it1.iter();
    loop {
    let (name, chan) = if let Some(chan) = it0.next() {
    chan.map_err(|e| e.0)?
    } else if let Some((name, chan)) = it1.next() {
    (name.as_ref(), chan.clone())
    } else {
    break
    };
    debug!(target: "drop_channel", "channel: {:?}", name);
  • edit in libpijul/src/pristine/sanakirja.rs at line 1973
    [3.2243]
    [3.2243]
    // This other channel is in the same state as
    // our dropped channel is, so all subsequent
    // patches are in use.
  • edit in libpijul/src/pristine/sanakirja.rs at line 1983
    [3.2470]
    [3.2470]
    // This channel has a patch, move on.
  • edit in libpijul/src/pristine/sanakirja.rs at line 1987
    [4.769]
    [4.769]
    debug!(target: "drop_channel", "actually unused: {:?}", p);
  • replacement in libpijul/src/pristine/sanakirja.rs at line 2001
    [4.417][4.417:497]()
    btree::del(&mut self.txn, &mut self.revdep, &k, Some(&v))?;
    [4.417]
    [4.497]
    debug!(target: "drop_channel", "deleting from revdep: {:?} {:?}", k, v);
    btree::del(&mut self.txn, &mut self.dep, &k, Some(&v))?;