mirror of
https://github.com/RetroShare/libretroshare.git
synced 2026-09-14 11:05:45 +05:00
Fix stopping RetroShare process
Avoid crashing in rsGlobalShutDown() if called before login Avoid RS remaining active when stopped from Android when not yet logged in by calling rsGlobalShutDown() always
This commit is contained in:
parent
fcafb66b26
commit
20733fdc0b
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RetroShare Service Android
|
||||
* Copyright (C) 2016-2021 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net>
|
||||
* Copyright (C) 2016-2022 Gioacchino Mazzurco <gio@retroshare.cc>
|
||||
* Copyright (C) 2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@ -65,7 +65,7 @@ RetroShareServiceAndroid::start(
|
||||
conf.jsonApiPort = static_cast<uint16_t>(jsonApiPort);
|
||||
conf.jsonApiBindAddress = jni::Make<std::string>(env, jsonApiBindAddress);
|
||||
|
||||
// Dirty workaround plugins not supported on Android ATM
|
||||
// Dirty workaround, plugins not supported on Android ATM
|
||||
conf.main_executable_path = " ";
|
||||
|
||||
int initResult = RsInit::InitRetroShare(conf);
|
||||
@ -81,15 +81,12 @@ RetroShareServiceAndroid::start(
|
||||
jni::Local<jni::Object<ErrorConditionWrap>> RetroShareServiceAndroid::stop(
|
||||
JNIEnv& env, jni::Class<RetroShareServiceAndroid>& )
|
||||
{
|
||||
if(RsControl::instance()->isReady())
|
||||
{
|
||||
RsControl::instance()->rsGlobalShutDown();
|
||||
return jni::Make<ErrorConditionWrap>(env, std::error_condition());
|
||||
}
|
||||
RsControl::instance()->rsGlobalShutDown();
|
||||
|
||||
// Stop also the cout/cerr catcher which uses threads internally
|
||||
sAndroidCoutCerrCatcher.reset();
|
||||
|
||||
return jni::Make<ErrorConditionWrap>(env, std::errc::no_such_process);
|
||||
return jni::Make<ErrorConditionWrap>(env, std::error_condition());
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<RetroShareServiceAndroid::Context> >
|
||||
|
||||
@ -81,43 +81,32 @@ void RsServer::startServiceThread(RsTickingThread *t, const std::string &threadN
|
||||
|
||||
void RsServer::rsGlobalShutDown()
|
||||
{
|
||||
bool wasReady = coreReady;
|
||||
coreReady = false;
|
||||
// TODO: cache should also clean up old files
|
||||
|
||||
ConfigFinalSave(); // save configuration before exit
|
||||
if(wasReady)
|
||||
{
|
||||
// save configuration before exit
|
||||
ConfigFinalSave();
|
||||
|
||||
mPluginsManager->stopPlugins(pqih);
|
||||
mPluginsManager->stopPlugins(pqih);
|
||||
|
||||
mNetMgr->shutdown(); /* Handles UPnP */
|
||||
/* Handles UPnP */
|
||||
mNetMgr->shutdown();
|
||||
|
||||
rsAutoProxyMonitor::instance()->stopAllRSShutdown();
|
||||
|
||||
// kill all registered service threads
|
||||
for(RsTickingThread* service: mRegisteredServiceThreads)
|
||||
service->fullstop();
|
||||
}
|
||||
|
||||
fullstop();
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
rsJsonApi->fullstop();
|
||||
#endif
|
||||
|
||||
rsAutoProxyMonitor::instance()->stopAllRSShutdown();
|
||||
|
||||
fullstop() ;
|
||||
|
||||
// kill all registered service threads
|
||||
|
||||
for(std::list<RsTickingThread*>::iterator it= mRegisteredServiceThreads.begin();it!=mRegisteredServiceThreads.end();++it)
|
||||
{
|
||||
(*it)->fullstop() ;
|
||||
}
|
||||
// #ifdef RS_ENABLE_GXS
|
||||
// // We should automate this.
|
||||
// //
|
||||
// if(mGxsCircles) mGxsCircles->join();
|
||||
// if(mGxsForums) mGxsForums->join();
|
||||
// if(mGxsChannels) mGxsChannels->join();
|
||||
// if(mGxsIdService) mGxsIdService->join();
|
||||
// if(mPosted) mPosted->join();
|
||||
// if(mWiki) mWiki->join();
|
||||
// if(mGxsNetService) mGxsNetService->join();
|
||||
// if(mPhoto) mPhoto->join();
|
||||
// if(mWire) mWire->join();
|
||||
// #endif
|
||||
|
||||
AuthPGP::exit();
|
||||
|
||||
mShutdownCallback(0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user