Skip to content

Commit

Permalink
Merge pull request #28 from payload/fix/supervisor-panic
Browse files Browse the repository at this point in the history
Don't call rx.next after receiving None, fixes #27
  • Loading branch information
sunli829 authored Sep 28, 2020
2 parents 8a7e089 + d83a870 commit f36533d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ impl Supervisor {

spawn({
async move {
loop {
while let Some(event) = rx.next().await {
match event {
ActorEvent::Exec(f) => f(&mut actor, &mut ctx).await,
ActorEvent::Stop(_err) => break,
ActorEvent::RemoveStream(id) => {
'restart_loop: loop {
'event_loop: loop {
match rx.next().await {
None => break 'restart_loop,
Some(ActorEvent::Stop(_err)) => break 'event_loop,
Some(ActorEvent::Exec(f)) => f(&mut actor, &mut ctx).await,
Some(ActorEvent::RemoveStream(id)) => {
if ctx.streams.contains(id) {
ctx.streams.remove(id);
}
Expand All @@ -104,10 +105,11 @@ impl Supervisor {
}

actor.stopped(&mut ctx).await;

actor = f();
actor.started(&mut ctx).await.ok();
}

actor.stopped(&mut ctx).await;
}
});

Expand Down

0 comments on commit f36533d

Please sign in to comment.