Properly propagate errors in `libpijul::record::record` instead of unwrap()ing

pmeunier
Jul 4, 2021, 6:20 PM
AJEH3FSPKLBYSRQQQ4UL4QA3SPT4MHIC4VEM3XDVATMFFU3R7JKAC

Dependencies

  • [2] I24UEJQL Various post-fire fixes
  • [3] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [4] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump

Change contents

  • replacement in libpijul/src/record.rs at line 300
    [2.45087][2.45087:45159]()
    let mut workers: Vec<std::thread::JoinHandle<()>> = Vec::new();
    [2.45087]
    [2.45159]
    let mut workers: Vec<std::thread::JoinHandle<_>> = Vec::new();
  • replacement in libpijul/src/record.rs at line 308
    [2.45425][2.45425:46593]()
    workers.push(std::thread::spawn(move || loop {
    let (w, stop) = {
    let mut work = work.lock().unwrap();
    (work.t.pop_front(), work.stop)
    };
    if let Some((item, vertex, rec, new_papa)) = w {
    // This parent has changed.
    info!("record existing file {:?} on thread {:?}", item, t);
    rec.lock()
    .unwrap()
    .record_existing_file(
    txn.clone(),
    diff_algorithm,
    channel.clone(),
    working_copy.clone(),
    &changes,
    &item,
    new_papa,
    vertex,
    )
    .unwrap();
    } else if stop {
    info!("stop {:?}", t);
    break;
    } else {
    info!("yield {:?}", t);
    std::thread::park_timeout(std::time::Duration::from_secs(1));
    [2.45425]
    [2.46593]
    workers.push(std::thread::spawn(move || {
    loop {
    let (w, stop) = {
    let mut work = work.lock().unwrap();
    (work.t.pop_front(), work.stop)
    };
    if let Some((item, vertex, rec, new_papa)) = w {
    // This parent has changed.
    info!("record existing file {:?} on thread {:?}", item, t);
    rec.lock()
    .unwrap()
    .record_existing_file(
    txn.clone(),
    diff_algorithm,
    channel.clone(),
    working_copy.clone(),
    &changes,
    &item,
    new_papa,
    vertex,
    )?;
    } else if stop {
    info!("stop {:?}", t);
    break;
    } else {
    info!("yield {:?}", t);
    std::thread::park_timeout(std::time::Duration::from_secs(1));
    }
  • edit in libpijul/src/record.rs at line 337
    [2.46611]
    [2.46611]
    Ok::<_, RecordError<C::Error, W::Error, T::GraphError>>(())
  • replacement in libpijul/src/record.rs at line 462
    [2.50222][2.50222:50275]()
    )
    .unwrap();
    [2.50222]
    [2.50275]
    )?;
  • replacement in libpijul/src/record.rs at line 469
    [2.50438][2.50438:50468]()
    t.join().unwrap()
    [2.50438]
    [3.495465]
    match t.join() {
    Ok(x) => x?,
    Err(e) => {
    warn!("Thread error {:?}", e);
    }
    }