Skip to content

Commit

Permalink
Ensure LocalNode to be stoped before shutting down the NeoSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Feb 20, 2019
1 parent d9fc9e9 commit 2bff318
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Neo.Wallets;
using System;
using System.Net;
using System.Threading;

namespace Neo
{
Expand Down Expand Up @@ -40,10 +41,18 @@ public NeoSystem(Store store)
public void Dispose()
{
RpcServer?.Dispose();
ActorSystem.Stop(LocalNode);
EnsureStoped(LocalNode);
ActorSystem.Dispose();
}

public void EnsureStoped(IActorRef actor)
{
Inbox inbox = Inbox.Create(ActorSystem);
inbox.Watch(actor);
ActorSystem.Stop(actor);
inbox.Receive(Timeout.InfiniteTimeSpan);

This comment has been minimized.

Copy link
@jsolman

jsolman Mar 1, 2019

Contributor

This may not be working, or perhaps we need to try catch around this. It’s throwing System.TimeoutException: Inbox akka://NeoSystem/system/inbox-1 received a status failure response message: Deadline passed ---> System.TimeoutException: Deadline passed

This comment has been minimized.

Copy link
@jsolman

jsolman Mar 1, 2019

Contributor

I've looked into it and discovered that the issue is that Timeout.InfiniteTimeSpan is not properly supported by inbox.Receive. Using a long timeout though such as 1 minute is completely reasonable and fixes the issue. I will create a PR.

}

internal void ResumeNodeStartup()
{
suspend = false;
Expand Down

0 comments on commit 2bff318

Please sign in to comment.