mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
rpc: misc tweaks
- make the execute flag int and volatile (used as signal comms) - do not execute all the RPC shutdown in the signal context - do not busy wait while waiting for the signal
This commit is contained in:
parent
cc2a3aadad
commit
3ca7c008db
@ -43,25 +43,30 @@
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
static bool execute = true;
|
||||
static volatile int execute = 1;
|
||||
void trap(int signal) {
|
||||
RPC::DaemonDeprecated::stop();
|
||||
execute = false;
|
||||
execute = 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
bool initialized = false;
|
||||
int res = RPC::DaemonDeprecated::start();
|
||||
if (res == RPC::DaemonDeprecated::FAILURE_HTTP_SERVER) {
|
||||
std::cerr << "Couldn't start HTTP server\n";
|
||||
execute = false;
|
||||
execute = 0;
|
||||
} else if (res == RPC::DaemonDeprecated::FAILURE_DAEMON_NOT_RUNNING) {
|
||||
std::cerr << "Couldn't connect to daemon\n";
|
||||
execute = false;
|
||||
execute = 0;
|
||||
} else {
|
||||
initialized = true;
|
||||
}
|
||||
signal(SIGINT, &trap);
|
||||
while (execute) {
|
||||
|
||||
epee::misc_utils::sleep_no_w(100); // 100 ms
|
||||
}
|
||||
signal(SIGINT, SIG_DFL);
|
||||
if (initialized)
|
||||
RPC::DaemonDeprecated::stop();
|
||||
std::cout << "out!\n";
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user