mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed memory leak in request handling by adding a destructor the the request classes derived from GxsRequest and delete the result.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7876 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
481ee246b5
commit
301e8e7019
@ -412,6 +412,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpM
|
||||
if(gmreq)
|
||||
{
|
||||
groupInfo = gmreq->mGroupMetaData;
|
||||
gmreq->mGroupMetaData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req found, failed caste" << std::endl;
|
||||
@ -442,6 +443,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
||||
if(gmreq)
|
||||
{
|
||||
grpData = gmreq->mGroupData;
|
||||
gmreq->mGroupData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Req found, failed caste" << std::endl;
|
||||
@ -473,6 +475,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
|
||||
if(mdreq)
|
||||
{
|
||||
msgData = mdreq->mMsgData;
|
||||
mdreq->mMsgData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else
|
||||
@ -509,6 +512,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData
|
||||
if(mrireq)
|
||||
{
|
||||
msgData = mrireq->mMsgDataResult;
|
||||
mrireq->mMsgDataResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else
|
||||
@ -542,6 +546,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
|
||||
if(mmreq)
|
||||
{
|
||||
msgInfo = mmreq->mMsgMetaData;
|
||||
mmreq->mMsgMetaData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
|
||||
}
|
||||
@ -581,6 +586,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta
|
||||
if(mrireq)
|
||||
{
|
||||
msgMeta = mrireq->mMsgMetaResult;
|
||||
mrireq->mMsgMetaResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else
|
||||
@ -619,6 +625,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul
|
||||
if(mrireq)
|
||||
{
|
||||
msgIds = mrireq->mMsgIdResult;
|
||||
mrireq->mMsgIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else{
|
||||
@ -652,6 +659,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
|
||||
if(mireq)
|
||||
{
|
||||
msgIds = mireq->mMsgIdResult;
|
||||
mireq->mMsgIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else{
|
||||
@ -684,6 +692,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
|
||||
if(gireq)
|
||||
{
|
||||
groupIds = gireq->mGroupIdResult;
|
||||
gireq->mGroupIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
|
||||
}else{
|
||||
|
61
libretroshare/src/gxs/rsgxsrequesttypes.cc
Normal file
61
libretroshare/src/gxs/rsgxsrequesttypes.cc
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* libretroshare/src/gxs: rgxsrequesttypes.cc
|
||||
*
|
||||
* Type introspect request types for data access request implementation
|
||||
*
|
||||
* Copyright 2012-2012 by Christopher Evi-Parker
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rsgxsrequesttypes.h"
|
||||
#include "util/rsstd.h"
|
||||
|
||||
GroupMetaReq::~GroupMetaReq()
|
||||
{
|
||||
rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end());
|
||||
}
|
||||
|
||||
GroupDataReq::~GroupDataReq()
|
||||
{
|
||||
rsstd::delete_all(mGroupData.begin(), mGroupData.end());
|
||||
}
|
||||
|
||||
MsgMetaReq::~MsgMetaReq()
|
||||
{
|
||||
for (GxsMsgMetaResult::iterator it = mMsgMetaData.begin(); it != mMsgMetaData.end(); ++it) {
|
||||
rsstd::delete_all(it->second.begin(), it->second.end());
|
||||
}
|
||||
}
|
||||
|
||||
MsgDataReq::~MsgDataReq()
|
||||
{
|
||||
for (NxsMsgDataResult::iterator it = mMsgData.begin(); it != mMsgData.end(); ++it) {
|
||||
rsstd::delete_all(it->second.begin(), it->second.end());
|
||||
}
|
||||
}
|
||||
|
||||
MsgRelatedInfoReq::~MsgRelatedInfoReq()
|
||||
{
|
||||
for (MsgRelatedMetaResult::iterator metaIt = mMsgMetaResult.begin(); metaIt != mMsgMetaResult.end(); ++metaIt) {
|
||||
rsstd::delete_all(metaIt->second.begin(), metaIt->second.end());
|
||||
}
|
||||
for (NxsMsgRelatedDataResult::iterator dataIt = mMsgDataResult.begin(); dataIt != mMsgDataResult.end(); ++dataIt) {
|
||||
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
|
||||
}
|
||||
}
|
@ -31,23 +31,24 @@
|
||||
|
||||
class GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~GxsRequest() {}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
virtual ~GxsRequest() { return; }
|
||||
uint32_t token;
|
||||
uint32_t reqTime;
|
||||
|
||||
uint32_t ansType;
|
||||
uint32_t reqType;
|
||||
RsTokReqOptions Options;
|
||||
RsTokReqOptions Options;
|
||||
|
||||
uint32_t status;
|
||||
};
|
||||
|
||||
class GroupMetaReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~GroupMetaReq();
|
||||
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
@ -56,41 +57,42 @@ public:
|
||||
|
||||
class GroupIdReq : public GxsRequest
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIdResult;
|
||||
};
|
||||
|
||||
class GroupDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~GroupDataReq();
|
||||
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
|
||||
class MsgIdReq : public GxsRequest
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
GxsMsgReq mMsgIds;
|
||||
GxsMsgIdResult mMsgIdResult;
|
||||
};
|
||||
|
||||
class MsgMetaReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~MsgMetaReq();
|
||||
|
||||
public:
|
||||
GxsMsgReq mMsgIds;
|
||||
GxsMsgMetaResult mMsgMetaData;
|
||||
GxsMsgMetaResult mMsgMetaData;
|
||||
};
|
||||
|
||||
class MsgDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~MsgDataReq();
|
||||
|
||||
public:
|
||||
GxsMsgReq mMsgIds;
|
||||
@ -100,30 +102,31 @@ public:
|
||||
class ServiceStatisticRequest: public GxsRequest
|
||||
{
|
||||
public:
|
||||
GxsServiceStatistic mServiceStatistic;
|
||||
GxsServiceStatistic mServiceStatistic;
|
||||
};
|
||||
|
||||
struct GroupStatisticRequest: public GxsRequest
|
||||
{
|
||||
public:
|
||||
RsGxsGroupId mGrpId;
|
||||
GxsGroupStatistic mGroupStatistic;
|
||||
RsGxsGroupId mGrpId;
|
||||
GxsGroupStatistic mGroupStatistic;
|
||||
};
|
||||
|
||||
class MsgRelatedInfoReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
virtual ~MsgRelatedInfoReq();
|
||||
|
||||
public:
|
||||
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
||||
MsgRelatedIdResult mMsgIdResult;
|
||||
MsgRelatedMetaResult mMsgMetaResult;
|
||||
NxsMsgRelatedDataResult mMsgDataResult;
|
||||
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
||||
MsgRelatedIdResult mMsgIdResult;
|
||||
MsgRelatedMetaResult mMsgMetaResult;
|
||||
NxsMsgRelatedDataResult mMsgDataResult;
|
||||
};
|
||||
|
||||
class GroupSetFlagReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
|
||||
const static uint32_t FLAG_SUBSCRIBE;
|
||||
const static uint32_t FLAG_STATUS;
|
||||
|
||||
@ -131,13 +134,11 @@ public:
|
||||
uint32_t flag;
|
||||
uint32_t flagMask;
|
||||
RsGxsGroupId grpId;
|
||||
|
||||
};
|
||||
|
||||
class MessageSetFlagReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
|
||||
const static uint32_t FLAG_STATUS;
|
||||
|
||||
uint8_t type;
|
||||
@ -146,5 +147,4 @@ public:
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
};
|
||||
|
||||
|
||||
#endif /* RSGXSREQUESTTYPES_H_ */
|
||||
|
@ -452,6 +452,7 @@ HEADERS += util/folderiterator.h \
|
||||
util/dnsresolver.h \
|
||||
util/rsprint.h \
|
||||
util/rsstring.h \
|
||||
util/rsstd.h \
|
||||
util/rsthreads.h \
|
||||
util/rsversioninfo.h \
|
||||
util/rswin.h \
|
||||
@ -680,7 +681,8 @@ gxs {
|
||||
gxs/rsgxsifacehelper.h \
|
||||
gxs/gxstokenqueue.h \
|
||||
gxs/rsgxsnetutils.h \
|
||||
gxs/rsgxsiface.h
|
||||
gxs/rsgxsiface.h \
|
||||
gxs/rsgxsrequesttypes.h
|
||||
|
||||
|
||||
SOURCES += serialiser/rsnxsitems.cc \
|
||||
@ -696,7 +698,8 @@ gxs {
|
||||
gxs/gxssecurity.cc \
|
||||
gxs/gxstokenqueue.cc \
|
||||
gxs/rsgxsnetutils.cc \
|
||||
gxs/rsgxsutil.cc
|
||||
gxs/rsgxsutil.cc \
|
||||
gxs/rsgxsrequesttypes.cc
|
||||
|
||||
|
||||
# Identity Service
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
* @param msgInfo the message metadata returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
bool getMsgrelatedSummary(const uint32_t &token, GxsMsgRelatedMetaMap &msgInfo)
|
||||
bool getMsgRelatedSummary(const uint32_t &token, GxsMsgRelatedMetaMap &msgInfo)
|
||||
{
|
||||
return mGxs->getMsgRelatedMeta(token, msgInfo);
|
||||
}
|
||||
|
37
libretroshare/src/util/rsstd.h
Normal file
37
libretroshare/src/util/rsstd.h
Normal file
@ -0,0 +1,37 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2015, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef RSSTD_H_
|
||||
#define RSSTD_H_
|
||||
|
||||
namespace rsstd {
|
||||
|
||||
template<typename _IIter>
|
||||
void delete_all(_IIter iter_begin, _IIter iter_end)
|
||||
{
|
||||
for (_IIter it = iter_begin; it != iter_end; ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // RSSTD_H_
|
Loading…
Reference in New Issue
Block a user