fix buggy "merge_two_streams"

This commit is contained in:
Igor Katson 2024-08-18 17:37:03 +01:00
parent 675aecf44b
commit d028e2e3c2
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 41 additions and 11 deletions

View file

@ -320,6 +320,8 @@ impl ManagedTorrent {
let live =
TorrentStateLive::new(paused, tx, live_cancellation_token)?;
g.state = ManagedTorrentState::Live(live.clone());
drop(g);
t.state_change_notify.notify_waiters();
spawn_fatal_errors_receiver(&t, rx, token);
@ -343,6 +345,8 @@ impl ManagedTorrent {
let (tx, rx) = tokio::sync::oneshot::channel();
let live = TorrentStateLive::new(paused, tx, live_cancellation_token.clone())?;
g.state = ManagedTorrentState::Live(live.clone());
drop(g);
spawn_fatal_errors_receiver(self, rx, live_cancellation_token);
spawn_peer_adder(&live, peer_rx);
Ok(())
@ -354,9 +358,10 @@ impl ManagedTorrent {
self.storage_factory.create_and_init(self.info())?,
));
g.state = ManagedTorrentState::Initializing(initializing.clone());
self.state_change_notify.notify_waiters();
drop(g);
self.state_change_notify.notify_waiters();
// Recurse.
self.start(
peer_rx,