Merge pull request #909 from csoler/v0.6-GxsTransport

V0.6 gxs transport
This commit is contained in:
csoler 2017-06-29 18:38:10 +02:00 committed by GitHub
commit 1b4e8a46ed
2 changed files with 11 additions and 6 deletions

View File

@ -20,7 +20,7 @@
#include "gxstrans/p3gxstrans.h" #include "gxstrans/p3gxstrans.h"
#include "util/stacktrace.h" #include "util/stacktrace.h"
#define DEBUG_GXSTRANS 1 //#define DEBUG_GXSTRANS 1
typedef unsigned int uint; typedef unsigned int uint;
@ -183,6 +183,10 @@ void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type)
const RsGroupMetaData& meta = grp->meta; const RsGroupMetaData& meta = grp->meta;
bool subscribed = IS_GROUP_SUBSCRIBED(meta.mSubscribeFlags); bool subscribed = IS_GROUP_SUBSCRIBED(meta.mSubscribeFlags);
// if mLastPost is 0, then the group is not subscribed, so it only has impact on shouldSubscribe. In any case, a group
// with no information shouldn't be subscribed, so the olderThen() test is still valid in the case mLastPost=0.
bool old = olderThen( meta.mLastPost, UNUSED_GROUP_UNSUBSCRIBE_INTERVAL ); bool old = olderThen( meta.mLastPost, UNUSED_GROUP_UNSUBSCRIBE_INTERVAL );
uint32_t token; uint32_t token;
@ -190,8 +194,9 @@ void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type)
bool shouldUnSubscribe = false ; bool shouldUnSubscribe = false ;
{ {
RS_STACK_MUTEX(mDataMutex); RS_STACK_MUTEX(mDataMutex);
bool shouldSubscribe = !subscribed && ( !old || meta.mGroupId == mPreferredGroupId );
bool shouldUnSubscribe = subscribed && old && meta.mGroupId != mPreferredGroupId; shouldSubscribe = (!subscribed) && ((!old)|| meta.mGroupId == mPreferredGroupId );
shouldUnSubscribe = ( subscribed) && old && meta.mGroupId != mPreferredGroupId;
} }
#ifdef DEBUG_GXSTRANS #ifdef DEBUG_GXSTRANS

View File

@ -150,12 +150,12 @@ public:
/// @see RsGenExchange::getServiceInfo() /// @see RsGenExchange::getServiceInfo()
virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); } virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); }
static const uint32_t GXS_STORAGE_PERIOD = 0x127500; // 14 days. static const uint32_t GXS_STORAGE_PERIOD = 15*86400; // 15 days.
static const uint32_t GXS_SYNC_PERIOD = 0x127500; static const uint32_t GXS_SYNC_PERIOD = 15*86400;
private: private:
/** Time interval of inactivity before a distribution group is unsubscribed. /** Time interval of inactivity before a distribution group is unsubscribed.
* Approximatively 3 months seems ok ATM. */ * Approximatively 3 months seems ok ATM. */
const static int32_t UNUSED_GROUP_UNSUBSCRIBE_INTERVAL = 0x76A700; const static int32_t UNUSED_GROUP_UNSUBSCRIBE_INTERVAL = 16*86400; // 16 days
/** /**
* This should be as little as possible as the size of the database can grow * This should be as little as possible as the size of the database can grow