Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the exit command after installing the Oracle plugin causes the cli to become unresponsive #494

Closed
ProDog opened this issue Jan 30, 2021 · 6 comments · Fixed by #535

Comments

@ProDog
Copy link
Contributor

ProDog commented Jan 30, 2021

Describe the bug
Using the exit command after installing the OracleService plugin causes the neo-cli to become unresponsive.

To Reproduce
Steps to reproduce the behavior:

  1. install OracleService plugin;
  2. start neo-cli;
  3. execute the exit command.

Expected behavior
Exit cli correctly.

Screenshots
image

Platform:

  • OS: [All]
  • Version [The latest master]
@shargon
Copy link
Member

shargon commented Jan 31, 2021

It's work for me, do you have anything else?

@ProDog
Copy link
Contributor Author

ProDog commented Jan 31, 2021

No, I just add OracleService plugin and it will appear. Removing the OracleService plugin and it will work.

@ProDog
Copy link
Contributor Author

ProDog commented Feb 1, 2021

Here into the loop and caused the bug.

public override void Dispose()
{
OnStop();
while (!stopped)
Thread.Sleep(100);
foreach (var p in protocols)
p.Value.Dispose();
}

private void OnStop()
{
cancelSource.Cancel();
if (timer != null)
{
timer.Dispose();
timer = null;
}
}

@erikzhang
Copy link
Member

private static async Task SendContentAsync(string url, string content)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.Timeout = 5000;
using (StreamWriter dataStream = new StreamWriter(await request.GetRequestStreamAsync()))
{
await dataStream.WriteAsync(content);
}
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
if (response.ContentLength > ushort.MaxValue) throw new Exception("The response it's bigger than allowed");
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
await reader.ReadToEndAsync();
}
catch (Exception e)
{
Log($"Failed to send the response signature to {url}, as {e.Message}", LogLevel.Warning);
}
}

This method needs to use CancellationToken.

@chenzhitong
Copy link
Member

Is this okay?

private void OnStop()
{
    cancelSource.Cancel();
    stopped = true; // add this line
    if (timer != null)
    {
        timer.Dispose();
        timer = null;
    }
}

@shargon
Copy link
Member

shargon commented Mar 3, 2021

@chenzhitong At the end of the method it should be ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants