new version "(27) Eckenhagen": add command line switch "--sync false" to disable automatic start of keysync at startup.

ENGINE-9
Roker 6 years ago
parent 52268f6ed2
commit 2593ce655b

@ -91,7 +91,8 @@ const std::string server_version =
// "(23) Engelskirchen"; // fix JSON-19. Support "Bool" and "Language" as separate data types in JavaScript.
// "(24) Bielstein"; // add MIME_encrypt_message_ex() and MIME_decrypt_message_ex() as a HACK.
// "(25) Gummersbach"; // JSON-22: add MIME_encrypt_message_for_self() and change API for encrypt_message_for_self().
"(26) Reichshof"; // change return type from JSON array into JSON object {"output":[...], "return":..., "errorstack":[...]}
// "(26) Reichshof"; // change return type from JSON array into JSON object {"output":[...], "return":..., "errorstack":[...]}
"(27) Eckenhagen"; // add command line switch "--sync false" to disable automatic start of keysync at startup
typedef std::map<std::thread::id, PEP_SESSION> SessionRegistry;
@ -668,6 +669,10 @@ void JsonAdapter::startSync()
void JsonAdapter::stopSync()
{
// No sync session active
if(i->sync_session == nullptr)
return
i->sync_queue.push_front(NULL);
i->sync_thread->join();
@ -678,7 +683,7 @@ void JsonAdapter::stopSync()
}
JsonAdapter::JsonAdapter(const std::string& address, unsigned start_port, unsigned end_port, bool silent)
JsonAdapter::JsonAdapter(const std::string& address, unsigned start_port, unsigned end_port, bool silent, bool do_sync)
: i(new Internal( silent ? nulllogger : std::cerr ))
{
i->eventBase.reset(event_base_new());
@ -694,7 +699,8 @@ JsonAdapter::JsonAdapter(const std::string& address, unsigned start_port, unsign
i->end_port = end_port;
i->silent = silent;
startSync();
if(do_sync)
startSync();
}

@ -11,8 +11,9 @@ class JsonAdapter : public Context
public:
// creates an instance of the JSON adapter. It tries to bind the first available port in the given range
// if chatty==true there is some debug output on stderr, if chatty==false the server is silent.
// only if do_sync== true the keysync thread is stared and the keysync callbacks are registered.
// throws std::runtime_error if no port cannot be bound.
JsonAdapter(const std::string& address, unsigned start_port, unsigned end_port, bool chatty);
JsonAdapter(const std::string& address, unsigned start_port, unsigned end_port, bool chatty, bool do_sync);
// calls shutdown() on the instance if it is still running().
virtual ~JsonAdapter();

@ -6,6 +6,7 @@
namespace po = boost::program_options;
bool debug_mode = false;
bool do_sync = false;
std::string address = "127.0.0.1";
unsigned start_port = 4223;
unsigned end_port = 9999;
@ -27,7 +28,8 @@ try
desc.add_options()
("help,h", "print this help messages")
("version,v", "print program version")
("debug,d", po::value<bool>(&debug_mode)->default_value(false), "Run in debug mode, don't fork() in background")
("debug,d" , po::value<bool>(&debug_mode)->default_value(false), "Run in debug mode, don't fork() in background: --debug true")
("sync" , po::value<bool>(&do_sync)->default_value(true) , "Start keysync in an asynchounous thread (default) or not (--sync false)")
("start-port,s", po::value<unsigned>(&start_port)->default_value(start_port), "First port to bind on")
("end-port,e", po::value<unsigned>(&end_port)->default_value(end_port), "Last port to bind on")
("address,a", po::value<std::string>(&address)->default_value(address), "Address to bind on")
@ -53,7 +55,7 @@ try
daemonize();
}
JsonAdapter ja( address, start_port, end_port, !debug_mode );
JsonAdapter ja( address, start_port, end_port, !debug_mode, do_sync );
ja.run();
if( debug_mode )

Loading…
Cancel
Save