mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -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
6 changed files with 135 additions and 25 deletions
|
@ -412,6 +412,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpM
|
||||||
if(gmreq)
|
if(gmreq)
|
||||||
{
|
{
|
||||||
groupInfo = gmreq->mGroupMetaData;
|
groupInfo = gmreq->mGroupMetaData;
|
||||||
|
gmreq->mGroupMetaData.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}else{
|
}else{
|
||||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req found, failed caste" << std::endl;
|
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)
|
if(gmreq)
|
||||||
{
|
{
|
||||||
grpData = gmreq->mGroupData;
|
grpData = gmreq->mGroupData;
|
||||||
|
gmreq->mGroupData.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}else{
|
}else{
|
||||||
std::cerr << "RsGxsDataAccess::getGroupData() Req found, failed caste" << std::endl;
|
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)
|
if(mdreq)
|
||||||
{
|
{
|
||||||
msgData = mdreq->mMsgData;
|
msgData = mdreq->mMsgData;
|
||||||
|
mdreq->mMsgData.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -509,6 +512,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData
|
||||||
if(mrireq)
|
if(mrireq)
|
||||||
{
|
{
|
||||||
msgData = mrireq->mMsgDataResult;
|
msgData = mrireq->mMsgDataResult;
|
||||||
|
mrireq->mMsgDataResult.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -542,6 +546,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
|
||||||
if(mmreq)
|
if(mmreq)
|
||||||
{
|
{
|
||||||
msgInfo = mmreq->mMsgMetaData;
|
msgInfo = mmreq->mMsgMetaData;
|
||||||
|
mmreq->mMsgMetaData.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -581,6 +586,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta
|
||||||
if(mrireq)
|
if(mrireq)
|
||||||
{
|
{
|
||||||
msgMeta = mrireq->mMsgMetaResult;
|
msgMeta = mrireq->mMsgMetaResult;
|
||||||
|
mrireq->mMsgMetaResult.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -619,6 +625,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul
|
||||||
if(mrireq)
|
if(mrireq)
|
||||||
{
|
{
|
||||||
msgIds = mrireq->mMsgIdResult;
|
msgIds = mrireq->mMsgIdResult;
|
||||||
|
mrireq->mMsgIdResult.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -652,6 +659,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
|
||||||
if(mireq)
|
if(mireq)
|
||||||
{
|
{
|
||||||
msgIds = mireq->mMsgIdResult;
|
msgIds = mireq->mMsgIdResult;
|
||||||
|
mireq->mMsgIdResult.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -684,6 +692,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
|
||||||
if(gireq)
|
if(gireq)
|
||||||
{
|
{
|
||||||
groupIds = gireq->mGroupIdResult;
|
groupIds = gireq->mGroupIdResult;
|
||||||
|
gireq->mGroupIdResult.clear();
|
||||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||||
|
|
||||||
}else{
|
}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
|
class GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~GxsRequest() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
virtual ~GxsRequest() { return; }
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
uint32_t reqTime;
|
uint32_t reqTime;
|
||||||
|
|
||||||
uint32_t ansType;
|
uint32_t ansType;
|
||||||
uint32_t reqType;
|
uint32_t reqType;
|
||||||
RsTokReqOptions Options;
|
RsTokReqOptions Options;
|
||||||
|
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupMetaReq : public GxsRequest
|
class GroupMetaReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~GroupMetaReq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
|
@ -56,41 +57,42 @@ public:
|
||||||
|
|
||||||
class GroupIdReq : public GxsRequest
|
class GroupIdReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<RsGxsGroupId> mGroupIdResult;
|
std::list<RsGxsGroupId> mGroupIdResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupDataReq : public GxsRequest
|
class GroupDataReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~GroupDataReq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<RsNxsGrp*> mGroupData;
|
std::list<RsNxsGrp*> mGroupData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MsgIdReq : public GxsRequest
|
class MsgIdReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
GxsMsgIdResult mMsgIdResult;
|
GxsMsgIdResult mMsgIdResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MsgMetaReq : public GxsRequest
|
class MsgMetaReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MsgMetaReq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
GxsMsgMetaResult mMsgMetaData;
|
GxsMsgMetaResult mMsgMetaData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MsgDataReq : public GxsRequest
|
class MsgDataReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MsgDataReq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
|
@ -100,30 +102,31 @@ public:
|
||||||
class ServiceStatisticRequest: public GxsRequest
|
class ServiceStatisticRequest: public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GxsServiceStatistic mServiceStatistic;
|
GxsServiceStatistic mServiceStatistic;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GroupStatisticRequest: public GxsRequest
|
struct GroupStatisticRequest: public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGxsGroupId mGrpId;
|
RsGxsGroupId mGrpId;
|
||||||
GxsGroupStatistic mGroupStatistic;
|
GxsGroupStatistic mGroupStatistic;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MsgRelatedInfoReq : public GxsRequest
|
class MsgRelatedInfoReq : public GxsRequest
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MsgRelatedInfoReq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
||||||
MsgRelatedIdResult mMsgIdResult;
|
MsgRelatedIdResult mMsgIdResult;
|
||||||
MsgRelatedMetaResult mMsgMetaResult;
|
MsgRelatedMetaResult mMsgMetaResult;
|
||||||
NxsMsgRelatedDataResult mMsgDataResult;
|
NxsMsgRelatedDataResult mMsgDataResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupSetFlagReq : public GxsRequest
|
class GroupSetFlagReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const static uint32_t FLAG_SUBSCRIBE;
|
const static uint32_t FLAG_SUBSCRIBE;
|
||||||
const static uint32_t FLAG_STATUS;
|
const static uint32_t FLAG_STATUS;
|
||||||
|
|
||||||
|
@ -131,13 +134,11 @@ public:
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
uint32_t flagMask;
|
uint32_t flagMask;
|
||||||
RsGxsGroupId grpId;
|
RsGxsGroupId grpId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MessageSetFlagReq : public GxsRequest
|
class MessageSetFlagReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const static uint32_t FLAG_STATUS;
|
const static uint32_t FLAG_STATUS;
|
||||||
|
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
@ -146,5 +147,4 @@ public:
|
||||||
RsGxsGrpMsgIdPair msgId;
|
RsGxsGrpMsgIdPair msgId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* RSGXSREQUESTTYPES_H_ */
|
#endif /* RSGXSREQUESTTYPES_H_ */
|
||||||
|
|
|
@ -452,6 +452,7 @@ HEADERS += util/folderiterator.h \
|
||||||
util/dnsresolver.h \
|
util/dnsresolver.h \
|
||||||
util/rsprint.h \
|
util/rsprint.h \
|
||||||
util/rsstring.h \
|
util/rsstring.h \
|
||||||
|
util/rsstd.h \
|
||||||
util/rsthreads.h \
|
util/rsthreads.h \
|
||||||
util/rsversioninfo.h \
|
util/rsversioninfo.h \
|
||||||
util/rswin.h \
|
util/rswin.h \
|
||||||
|
@ -680,7 +681,8 @@ gxs {
|
||||||
gxs/rsgxsifacehelper.h \
|
gxs/rsgxsifacehelper.h \
|
||||||
gxs/gxstokenqueue.h \
|
gxs/gxstokenqueue.h \
|
||||||
gxs/rsgxsnetutils.h \
|
gxs/rsgxsnetutils.h \
|
||||||
gxs/rsgxsiface.h
|
gxs/rsgxsiface.h \
|
||||||
|
gxs/rsgxsrequesttypes.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += serialiser/rsnxsitems.cc \
|
SOURCES += serialiser/rsnxsitems.cc \
|
||||||
|
@ -696,7 +698,8 @@ gxs {
|
||||||
gxs/gxssecurity.cc \
|
gxs/gxssecurity.cc \
|
||||||
gxs/gxstokenqueue.cc \
|
gxs/gxstokenqueue.cc \
|
||||||
gxs/rsgxsnetutils.cc \
|
gxs/rsgxsnetutils.cc \
|
||||||
gxs/rsgxsutil.cc
|
gxs/rsgxsutil.cc \
|
||||||
|
gxs/rsgxsrequesttypes.cc
|
||||||
|
|
||||||
|
|
||||||
# Identity Service
|
# Identity Service
|
||||||
|
|
|
@ -178,7 +178,7 @@ public:
|
||||||
* @param msgInfo the message metadata returned for given request token
|
* @param msgInfo the message metadata returned for given request token
|
||||||
* @return false if request token is invalid, check token status for error report
|
* @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);
|
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…
Add table
Add a link
Reference in a new issue