mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 22:22:45 -04:00
moved rsGlobalShutDown from MainWindow::doQuit to main
rsGlobalShutDown now cleans the threads and some memory on exit git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3028 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b80aef1228
commit
334c9b61d3
13 changed files with 61 additions and 16 deletions
|
@ -267,12 +267,16 @@ void FileIndexMonitor::run()
|
||||||
{
|
{
|
||||||
updateCycle();
|
updateCycle();
|
||||||
|
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(int i = 0; i < updatePeriod; i++)
|
for(int i = 0; i < updatePeriod; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (m_bRun == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
@ -207,7 +207,7 @@ void ftController::run()
|
||||||
/* check the queues */
|
/* check the queues */
|
||||||
uint32_t cnt = 0 ;
|
uint32_t cnt = 0 ;
|
||||||
|
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
|
|
|
@ -49,7 +49,7 @@ void ftExtraList::run()
|
||||||
time_t cleanup = 0;
|
time_t cleanup = 0;
|
||||||
time_t now = 0;
|
time_t now = 0;
|
||||||
|
|
||||||
while (1)
|
while (m_bRun)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ELIST
|
#ifdef DEBUG_ELIST
|
||||||
//std::cerr << "ftExtraList::run() Iteration";
|
//std::cerr << "ftExtraList::run() Iteration";
|
||||||
|
|
|
@ -191,6 +191,37 @@ void ftServer::StartupThreads()
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ftServer::StopThreads()
|
||||||
|
{
|
||||||
|
/* stop own thread */
|
||||||
|
join();
|
||||||
|
|
||||||
|
/* stop Dataplex */
|
||||||
|
mFtDataplex->join();
|
||||||
|
|
||||||
|
/* stop Controller thread */
|
||||||
|
mFtController->join();
|
||||||
|
|
||||||
|
/* stop Monitor Thread */
|
||||||
|
mFiMon->join();
|
||||||
|
|
||||||
|
/* self contained threads */
|
||||||
|
/* stop ExtraList Thread */
|
||||||
|
mFtExtra->join();
|
||||||
|
|
||||||
|
delete (mFtDataplex);
|
||||||
|
mFtDataplex = NULL;
|
||||||
|
|
||||||
|
delete (mFtController);
|
||||||
|
mFtController = NULL;
|
||||||
|
|
||||||
|
delete (mFiMon);
|
||||||
|
mFiMon = NULL;
|
||||||
|
|
||||||
|
delete (mFtExtra);
|
||||||
|
mFtExtra = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CacheStrapper *ftServer::getCacheStrapper()
|
CacheStrapper *ftServer::getCacheStrapper()
|
||||||
{
|
{
|
||||||
return mCacheStrapper;
|
return mCacheStrapper;
|
||||||
|
@ -203,7 +234,7 @@ CacheTransfer *ftServer::getCacheTransfer()
|
||||||
|
|
||||||
void ftServer::run()
|
void ftServer::run()
|
||||||
{
|
{
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
mFtDataplex->deleteUnusedServers() ;
|
mFtDataplex->deleteUnusedServers() ;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
|
@ -98,6 +98,7 @@ void SetupFtServer(NotifyBase *cb);
|
||||||
void connectToTurtleRouter(p3turtle *p) ;
|
void connectToTurtleRouter(p3turtle *p) ;
|
||||||
|
|
||||||
void StartupThreads();
|
void StartupThreads();
|
||||||
|
void StopThreads();
|
||||||
|
|
||||||
/* own thread */
|
/* own thread */
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
|
@ -170,5 +170,7 @@ void RsServer::rsGlobalShutDown()
|
||||||
mChannels->cleanUpOldFiles();
|
mChannels->cleanUpOldFiles();
|
||||||
ConfigFinalSave(); // save configuration before exit
|
ConfigFinalSave(); // save configuration before exit
|
||||||
mConnMgr->shutdown(); /* Handles UPnP */
|
mConnMgr->shutdown(); /* Handles UPnP */
|
||||||
}
|
|
||||||
|
|
||||||
|
join();
|
||||||
|
ftserver->StopThreads();
|
||||||
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ void RsServer::run()
|
||||||
int min = 0;
|
int min = 0;
|
||||||
int loop = 0;
|
int loop = 0;
|
||||||
|
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
usleep((int) (timeDelta * 1000000));
|
usleep((int) (timeDelta * 1000000));
|
||||||
|
|
|
@ -1508,7 +1508,6 @@ bool RsInit::RsStoreAutoLogin()
|
||||||
DataIn.cbData = cbDataInput;
|
DataIn.cbData = cbDataInput;
|
||||||
DataEnt.pbData = pbDataEnt;
|
DataEnt.pbData = pbDataEnt;
|
||||||
DataEnt.cbData = cbDataEnt;
|
DataEnt.cbData = cbDataEnt;
|
||||||
LPWSTR pDescrOut = NULL;
|
|
||||||
|
|
||||||
CRYPTPROTECT_PROMPTSTRUCT prom;
|
CRYPTPROTECT_PROMPTSTRUCT prom;
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ void UdpLayer::recv_loop()
|
||||||
int status;
|
int status;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
|
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
/* select on the socket TODO */
|
/* select on the socket TODO */
|
||||||
fd_set rset;
|
fd_set rset;
|
||||||
|
|
|
@ -80,8 +80,15 @@ pthread_t createThread(RsThread &thread)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsThread::RsThread ()
|
||||||
|
{
|
||||||
|
m_bRun = true;
|
||||||
|
}
|
||||||
|
|
||||||
void RsThread::join() /* waits for the the mTid thread to stop */
|
void RsThread::join() /* waits for the the mTid thread to stop */
|
||||||
{
|
{
|
||||||
|
m_bRun = false;
|
||||||
|
|
||||||
void *ptr;
|
void *ptr;
|
||||||
pthread_join(mTid, &ptr);
|
pthread_join(mTid, &ptr);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +107,7 @@ RsQueueThread::RsQueueThread(uint32_t min, uint32_t max, double relaxFactor )
|
||||||
|
|
||||||
void RsQueueThread::run()
|
void RsQueueThread::run()
|
||||||
{
|
{
|
||||||
while(1)
|
while(m_bRun)
|
||||||
{
|
{
|
||||||
bool doneWork = false;
|
bool doneWork = false;
|
||||||
while(workQueued() && doWork())
|
while(workQueued() && doWork())
|
||||||
|
|
|
@ -145,8 +145,8 @@ pthread_t createThread(RsThread &thread);
|
||||||
class RsThread
|
class RsThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsThread() { return; }
|
RsThread();
|
||||||
virtual ~RsThread() { return; }
|
virtual ~RsThread() {}
|
||||||
|
|
||||||
virtual void start() { createThread(*this); }
|
virtual void start() { createThread(*this); }
|
||||||
virtual void run() = 0; /* called once the thread is started */
|
virtual void run() = 0; /* called once the thread is started */
|
||||||
|
@ -155,6 +155,8 @@ virtual void stop(); /* calls pthread_exit() */
|
||||||
|
|
||||||
pthread_t mTid;
|
pthread_t mTid;
|
||||||
RsMutex mMutex;
|
RsMutex mMutex;
|
||||||
|
protected:
|
||||||
|
bool m_bRun;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -638,14 +638,12 @@ void MainWindow::doQuit()
|
||||||
|
|
||||||
if ((QMessageBox::question(this, tr("Really quit ? "),queryWrn,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
if ((QMessageBox::question(this, tr("Really quit ? "),queryWrn,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
rsicontrol->rsGlobalShutDown();
|
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
rsicontrol->rsGlobalShutDown();
|
|
||||||
rApp->quit();
|
rApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,10 +180,11 @@ int main(int argc, char *argv[])
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
|
||||||
/* dive into the endless loop */
|
/* dive into the endless loop */
|
||||||
// return ret;
|
|
||||||
int ti = rshare.exec();
|
int ti = rshare.exec();
|
||||||
delete w ;
|
delete w ;
|
||||||
|
|
||||||
|
rsicontrol->rsGlobalShutDown();
|
||||||
|
|
||||||
Settings->sync();
|
Settings->sync();
|
||||||
delete Settings;
|
delete Settings;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue