merge "default" into JSON-54 and solve some merge conflicts. I hope, I got all of them.

JSON-54
Roker 5 years ago
commit e1d6b5a37e

@ -172,6 +172,8 @@ const FunctionMap functions = {
FP( "version", new Func<std::string>( &JsonAdapter::version ) ),
FP( "apiVersion", new Func<unsigned> ( &JsonAdapter::apiVersion ) ),
FP( "getGpgEnvironment", new Func<GpgEnvironment>( &getGpgEnvironment ) ),
FP( "shutdown", new Func<void, In<JsonAdapter*, false>>( &JsonAdapter::shutdown_now ) ),
};

@ -103,7 +103,6 @@ struct EventListenerValue
struct JsonAdapter::Internal
{
std::unique_ptr<event_base, decltype(&event_base_free)> eventBase = {nullptr, &event_base_free};
@ -141,7 +140,8 @@ struct JsonAdapter::Internal
~Internal()
{
stopSync();
call_with_lock(&release, session);
if(session)
call_with_lock(&release, session);
session=nullptr;
}
@ -332,8 +332,6 @@ unsigned JsonAdapter::apiVersion()
PEP_STATUS JsonAdapter::messageToSend(void* obj, message* msg)
{
JsonAdapter* ja = static_cast<JsonAdapter*>(obj);
@ -509,9 +507,9 @@ JsonAdapter::~JsonAdapter()
Log() << "~JsonAdapter(): " << session_registry.size() << " sessions registered.\n";
stopSync();
this->shutdown(nullptr);
Log() << "\t After stopSync() and shutdown() there are " << session_registry.size() << " sessions registered.\n";
delete i;
i=nullptr;
Log() << "\t After stopSync() and shutdown() there are " << session_registry.size() << " sessions registered.\n";
}
@ -606,10 +604,10 @@ try_next_port:
}
catch (...)
{
Log() << " +++ UNKNOWN EXCEPTION in ThreadFunc +++ ";
Log() << " +++ UNKNOWN EXCEPTION in ThreadFunc +++ \n";
initExcept = std::current_exception();
}
Log() << " +++ Thread exit? isRun=" << i->running << ", id=" << std::this_thread::get_id() << ". +++\n";
Log() << " +++ Thread exit? isRun=" << i->running << ", id=" << std::this_thread::get_id() << ". initExcept is " << (initExcept?"":"not ") << "set. +++\n";
};
i->running = true;
@ -618,8 +616,9 @@ try_next_port:
Log() << "Start Thread #" << t << "...\n";
ThreadPtr thread(new std::thread(ThreadFunc), ThreadDeleter);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
if (initExcept != std::exception_ptr())
if (initExcept)
{
thread->join();
i->running = false;
std::rethrow_exception(initExcept);
}
@ -633,7 +632,7 @@ try_next_port:
}
catch (std::exception const &e)
{
Log() << "Exception catched in main(): \"" << e.what() << "\"" << std::endl;
Log() << "Exception caught in JsonAdapter::run(): \"" << e.what() << "\"" << std::endl;
throw;
}

@ -32,6 +32,8 @@ public:
// if "tv" is NULL it means: exits immediately after _all_ currently processed events have been finished.
void shutdown(struct timeval* tv);
void shutdown_now() { shutdown(nullptr); }
// exit immediately or after the currently processed event has been finished.
//void abort();

@ -56,12 +56,7 @@ try
print_version();
return 0;
}
if( !debug_mode )
{
daemonize();
}
JsonAdapter ja( address, start_port, end_port, !debug_mode, do_sync );
ja.run();
@ -75,6 +70,7 @@ try
std::cout << "Oh, I got a '" << input << "'. \n";
}while(std::cin && input != 'q' && input != 'Q');
}else{
daemonize();
do{
std::this_thread::sleep_for(std::chrono::seconds(3));
}while(ja.running());
@ -84,7 +80,12 @@ try
}
catch (std::exception const &e)
{
std::cerr << "Exception catched in main(): \"" << e.what() << "\"" << std::endl;
std::cerr << "Exception caught in main(): \"" << e.what() << "\"" << std::endl;
return 1;
}
catch (...)
{
std::cerr << "Unknown Exception caught in main()." << std::endl;
return 20;
}

Loading…
Cancel
Save