Merge pull request #1847 from csoler/v0.6-GxsDbFix

This branch aims at fixing the requests problems in RsGxsDataAccess
This commit is contained in:
csoler 2020-04-13 14:13:33 +02:00 committed by GitHub
commit b6c5e2f188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 1059 additions and 774 deletions

View file

@ -111,6 +111,7 @@ enum class RsChannelEventCode: uint8_t
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
};
struct RsGxsChannelEvent: RsEvent

View file

@ -111,6 +111,7 @@ enum class RsForumEventCode: uint8_t
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
};
struct RsGxsForumEvent: RsEvent

View file

@ -40,7 +40,9 @@
* are necessary, so at this point this workaround seems acceptable.
*/
#define DEBUG_GXSIFACEHELPER 1
//==================================
// #define DEBUG_GXSIFACEHELPER 1
//==================================
enum class TokenRequestType: uint8_t
{
@ -267,7 +269,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -295,7 +299,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -310,7 +316,9 @@ public:
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -324,7 +332,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::ALL_POSTS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -340,7 +350,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::MSG_RELATED_INFO;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -357,23 +369,33 @@ public:
/// @see RsTokenService::requestServiceStatistic
bool requestServiceStatistic(uint32_t& token)
{
mTokenService.requestServiceStatistic(token);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
mTokenService.requestServiceStatistic(token,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
/// @see RsTokenService::requestGroupStatistic
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
{
mTokenService.requestGroupStatistic(token, grpId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
mTokenService.requestGroupStatistic(token, grpId,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
@ -485,7 +507,7 @@ private:
uint32_t count[7] = {0};
std::cerr << "Service " << std::hex << service_id << std::dec
RsDbg() << "Service " << std::hex << service_id << std::dec
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;

View file

@ -45,6 +45,13 @@ struct RsMsgMetaData;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
enum class GxsRequestPriority {
VERY_HIGH = 0x00,
HIGH = 0x01,
NORMAL = 0x02,
LOW = 0x03,
VERY_LOW = 0x04,
};
class RsGxsGrpMetaData;
class RsGxsMsgMetaData;
@ -232,7 +239,7 @@ public:
mNumChildMsgsNew = 0;
mNumChildMsgsUnread = 0;
mSizeStore = 0;
}
}
public:
uint32_t mNumMsgs;

View file

@ -46,7 +46,8 @@ struct RsGxsNotify
TYPE_RECEIVED_NEW = 0x02,
TYPE_PROCESSED = 0x03,
TYPE_RECEIVED_PUBLISHKEY = 0x04,
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
TYPE_STATISTICS_CHANGED = 0x06
};
virtual ~RsGxsNotify() {}

View file

@ -114,6 +114,7 @@ enum class RsPostedEventCode: uint8_t
UPDATED_POSTED_GROUP = 0x04,
UPDATED_MESSAGE = 0x05,
READ_STATUS_CHANGED = 0x06,
STATISTICS_CHANGED = 0x07,
};

View file

@ -80,7 +80,7 @@ struct RsTokReqOptions
{
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
mSubscribeMask(0), mBefore(0), mAfter(0) {}
mSubscribeMask(0), mBefore(0), mAfter(0),mPriority(GxsRequestPriority::NORMAL) {}
/**
* Can be one or multiple RS_TOKREQOPT_*
@ -107,6 +107,8 @@ struct RsTokReqOptions
// Time range... again applied after Options.
rstime_t mBefore;
rstime_t mAfter;
GxsRequestPriority mPriority;
};
/*!
@ -181,6 +183,25 @@ public:
*/
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) = 0;
/* Poll */
@ -194,25 +215,6 @@ public:
*/
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
/*!
* @brief Cancel Request
* If this function returns false, it may be that the request has completed