From f9c896c3acd0f528bd25707da3027725a19d21a0 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 3 Apr 2011 16:20:47 +0000 Subject: [PATCH] Fixed crash on shutdown of RetroShare, when the cache loading is running. Now the p3distrib threads are stopped before the instance of AuthGPG is deleted. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4119 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/rsserver/p3face-config.cc | 10 ++++++++++ libretroshare/src/rsserver/p3face-server.cc | 1 + libretroshare/src/rsserver/p3face.h | 3 ++- libretroshare/src/rsserver/rsinit.cc | 2 +- libretroshare/src/services/p3distrib.cc | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/rsserver/p3face-config.cc b/libretroshare/src/rsserver/p3face-config.cc index 2b360dc68..d2eab9e45 100644 --- a/libretroshare/src/rsserver/p3face-config.cc +++ b/libretroshare/src/rsserver/p3face-config.cc @@ -180,5 +180,15 @@ void RsServer::rsGlobalShutDown() join(); ftserver->StopThreads(); + // stop the p3distrib threads +#ifndef MINIMAL_LIBRS + mForums->join(); + mChannels->join(); + +#ifdef RS_USE_BLOGS + mBlogs->join(); +#endif +#endif // MINIMAL_LIBRS + AuthGPGExit(); } diff --git a/libretroshare/src/rsserver/p3face-server.cc b/libretroshare/src/rsserver/p3face-server.cc index 6a2a746c0..34e3cb448 100644 --- a/libretroshare/src/rsserver/p3face-server.cc +++ b/libretroshare/src/rsserver/p3face-server.cc @@ -53,6 +53,7 @@ RsServer::RsServer(RsIface &i, NotifyBase &callback) chatSrv = NULL; mStatusSrv = NULL; mChannels = NULL; + mForums = NULL; /* caches (that need ticking) */ mRanking = NULL; diff --git a/libretroshare/src/rsserver/p3face.h b/libretroshare/src/rsserver/p3face.h index 8e88eaece..dac19ca1a 100644 --- a/libretroshare/src/rsserver/p3face.h +++ b/libretroshare/src/rsserver/p3face.h @@ -45,7 +45,7 @@ #include "services/p3blogs.h" #include "services/p3statusservice.h" #include "services/p3channels.h" - +#include "services/p3forums.h" /* The Main Interface Class - for controlling the server */ @@ -163,6 +163,7 @@ class RsServer: public RsControl, public RsThread p3ChatService *chatSrv; p3StatusService *mStatusSrv; p3Channels *mChannels; + p3Forums *mForums; /* caches (that need ticking) */ p3Ranking *mRanking; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index ca5f82527..2f07dd026 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1957,7 +1957,7 @@ int RsServer::StartupRetroShare() CachePair cp(mRanking, mRanking, CacheId(RS_SERVICE_TYPE_RANK, 0)); mCacheStrapper -> addCachePair(cp); /* end of declaration */ - p3Forums *mForums = new p3Forums(RS_SERVICE_TYPE_FORUM, + mForums = new p3Forums(RS_SERVICE_TYPE_FORUM, mCacheStrapper, mCacheTransfer, localcachedir, remotecachedir, forumdir); diff --git a/libretroshare/src/services/p3distrib.cc b/libretroshare/src/services/p3distrib.cc index 8e9880e94..82aeac397 100644 --- a/libretroshare/src/services/p3distrib.cc +++ b/libretroshare/src/services/p3distrib.cc @@ -862,7 +862,7 @@ void p3GroupDistrib::run() /* called once the thread is started */ int printed = 0; #endif CacheData cache; - while(1) + while(isRunning()) { /* */