mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-18 19:08:35 -04:00
added a temporary copy of mRequests in RsGxsDataAccess::processRequests() to avoid interactions with storeRequest() mofying the queue
This commit is contained in:
parent
25467dda9f
commit
9a1d589134
1 changed files with 15 additions and 12 deletions
|
@ -771,29 +771,32 @@ void RsGxsDataAccess::processRequests()
|
||||||
clearRequest(*cit);
|
clearRequest(*cit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We hve to make a copy of the mRequest list because it can be modified while we treat the requests.
|
||||||
|
// This may happen because the mutex cannot be added around the full loop since it takes too much time.
|
||||||
|
|
||||||
|
std::map<uint32_t,GxsRequest*> request_list_copy;
|
||||||
|
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mDataMutex);
|
||||||
|
request_list_copy = mRequests;
|
||||||
|
}
|
||||||
// process requests
|
// process requests
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
GxsRequest* req = NULL;
|
GxsRequest* req = NULL;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
|
||||||
|
|
||||||
// get the first pending request
|
// get the first pending request
|
||||||
for (it = mRequests.begin(); it != mRequests.end(); ++it)
|
for (auto it:request_list_copy)
|
||||||
|
if (it.second->status == PENDING)
|
||||||
{
|
{
|
||||||
GxsRequest* reqCheck = it->second;
|
req = it.second;
|
||||||
if (reqCheck->status == PENDING)
|
|
||||||
{
|
|
||||||
req = reqCheck;
|
|
||||||
req->status = PARTIAL;
|
req->status = PARTIAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // END OF MUTEX.
|
|
||||||
|
|
||||||
if (!req) {
|
if (!req)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
GroupMetaReq* gmr;
|
GroupMetaReq* gmr;
|
||||||
GroupDataReq* gdr;
|
GroupDataReq* gdr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue