Fix global shutdown call from JSON API

This commit is contained in:
Gioacchino Mazzurco 2020-01-27 23:40:18 +01:00
parent 5dbbe1ffd7
commit 8c9310f754
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
2 changed files with 9 additions and 3 deletions

View File

@ -248,7 +248,13 @@ JsonApiServer::JsonApiServer(): configMutex("JsonApiServer config"),
{
INITIALIZE_API_CALL_JSON_CONTEXT;
DEFAULT_API_CALL_JSON_RETURN(rb::OK);
rsControl->rsGlobalShutDown();
/* Wrap inside RsThread::async because this call
* RsThread::fullstop() also on JSON API server thread.
* Calling RsThread::fullstop() from it's own thread should never
* happen and if it happens an error message is printed
* accordingly by RsThread::fullstop() */
RsThread::async([](){ rsControl->rsGlobalShutDown(); });
} );
}, true);

View File

@ -397,8 +397,8 @@ int RsInit::InitRetroShare(const RsConfigOptions& conf)
#ifdef RS_JSONAPI
// We create the JsonApiServer this early, because it is needed *before* login
RsInfo() << __PRETTY_FUNCTION__
<< "Allocating jsonAPI server (not launched yet)" << std::endl;
RsDbg() << __PRETTY_FUNCTION__
<< " Allocating JSON API server (not launched yet)" << std::endl;
JsonApiServer* jas = new JsonApiServer();
jas->setListeningPort(conf.jsonApiPort);
jas->setBindingAddress(conf.jsonApiBindAddress);