From 8c9310f754aa51fd211d231672008edb12489ddb Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 27 Jan 2020 23:40:18 +0100 Subject: [PATCH] Fix global shutdown call from JSON API --- libretroshare/src/jsonapi/jsonapi.cpp | 8 +++++++- libretroshare/src/rsserver/rsinit.cc | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/jsonapi/jsonapi.cpp b/libretroshare/src/jsonapi/jsonapi.cpp index af7f8654a..832d07add 100644 --- a/libretroshare/src/jsonapi/jsonapi.cpp +++ b/libretroshare/src/jsonapi/jsonapi.cpp @@ -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); diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index db290ea63..2de431589 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -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);