Luminarys / synapse

Synapse BitTorrent Daemon
https://synapse-bt.org
ISC License
853 stars 48 forks source link

Fix panicking unwrap() in choker #153

Closed astro closed 4 years ago

astro commented 4 years ago

I have seen the following panic:

thread 'control' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
stack backtrace:
   0: std::sys_common::backtrace::print
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::continue_panic_fmt
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: synapse::torrent::choker::Choker::update_download
   9: <synapse::control::job::UnchokeUpdate as synapse::control::job::Job<T>>::update
  10: synapse::control::Control<T>::handle_event
  11: synapse::control::Control<T>::run

This commit prevents the panic for just one .unwrap(). I think there may be more locations where code like this can panic.

Luminarys commented 4 years ago

Thanks for this. More concerning is that assumptions about peer id presence is wrong here, I'll do some investigation into why this could occur.