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

Set cli_quitting to true in cli::cancel() #129

Merged
merged 2 commits into from
May 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions src/rpc/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@ void cli::send_notice( uint64_t callback_id, variants args /* = variants() */ )
FC_ASSERT(false);
}

void cli::stop()
{
cancel();
_run_complete.wait();
}

void cli::cancel()
{
_run_complete.cancel();
#ifdef HAVE_EDITLINE
if( _getline_thread )
{
_getline_thread->signal(SIGINT);
_getline_thread = nullptr;
}
#endif
}

void cli::wait()
{
_run_complete.wait();
}

void cli::format_result( const string& method, std::function<string(variant,const variants&)> formatter)
{
_result_formatters[method] = formatter;
Expand Down Expand Up @@ -267,7 +244,7 @@ static int interruptible_getc(void)
if( r == -1 && errno == EINTR )
cli_quitting = true;

return r == 1 ? c : EOF;
return r == 1 && !cli_quitting ? c : EOF;
}

void cli::start()
Expand All @@ -292,6 +269,30 @@ void cli::start()
_run_complete = fc::async( [this](){ run(); } );
}

void cli::cancel()
{
_run_complete.cancel();
#ifdef HAVE_EDITLINE
cli_quitting = true;
if( _getline_thread )
{
_getline_thread->signal(SIGINT);
_getline_thread = nullptr;
}
#endif
}

void cli::stop()
{
cancel();
_run_complete.wait();
}

void cli::wait()
{
_run_complete.wait();
}

/***
* @brief Read input from the user
* @param prompt the prompt to display
Expand Down