mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
merged before commit
This commit is contained in:
commit
d09b636cda
@ -59,7 +59,7 @@
|
|||||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE = 3;
|
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE = 3;
|
||||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
|
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
|
||||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
|
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
|
||||||
|
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_CANCELLED = 6;
|
||||||
|
|
||||||
/***********
|
/***********
|
||||||
* #define DATA_DEBUG 1
|
* #define DATA_DEBUG 1
|
||||||
@ -367,13 +367,19 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool RsGxsDataAccess::cancelRequest(const uint32_t& token)
|
bool RsGxsDataAccess::cancelRequest(const uint32_t& token)
|
||||||
{
|
{
|
||||||
return clearRequest(token);
|
RsStackMutex stack(mDataMutex); /****** LOCKED *****/
|
||||||
|
|
||||||
|
GxsRequest* req = locked_retrieveRequest(token);
|
||||||
|
if (!req)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
req->status = GXS_REQUEST_V2_STATUS_CANCELLED;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
||||||
@ -389,7 +395,7 @@ bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete it->second;
|
delete it->second;
|
||||||
mRequests.erase(it->first);
|
mRequests.erase(it);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -707,7 +713,6 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
|
GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -722,15 +727,84 @@ GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
|
|||||||
|
|
||||||
void RsGxsDataAccess::processRequests()
|
void RsGxsDataAccess::processRequests()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::list<uint32_t> toClear;
|
std::list<uint32_t> toClear;
|
||||||
std::list<uint32_t>::iterator cit;
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
std::map<uint32_t, GxsRequest*>::iterator it;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||||
|
|
||||||
std::map<uint32_t, GxsRequest*>::iterator it;
|
// process status of the requests
|
||||||
|
for (it = mRequests.begin(); it != mRequests.end(); ++it)
|
||||||
|
{
|
||||||
|
GxsRequest* req = it->second;
|
||||||
|
|
||||||
|
switch (req->status)
|
||||||
|
{
|
||||||
|
case GXS_REQUEST_V2_STATUS_PENDING:
|
||||||
|
// process request later
|
||||||
|
break;
|
||||||
|
case GXS_REQUEST_V2_STATUS_PARTIAL:
|
||||||
|
// should not happen
|
||||||
|
req->status = GXS_REQUEST_V2_STATUS_COMPLETE;
|
||||||
|
break;
|
||||||
|
case GXS_REQUEST_V2_STATUS_DONE:
|
||||||
|
#ifdef DATA_DEBUG
|
||||||
|
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: " << req->token;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
toClear.push_back(req->token);
|
||||||
|
break;
|
||||||
|
case GXS_REQUEST_V2_STATUS_CANCELLED:
|
||||||
|
#ifdef DATA_DEBUG
|
||||||
|
std::cerr << "RsGxsDataAccess::processrequests() Clearing Cancelled Request Token: " << req->token;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
toClear.push_back(req->token);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (now - req->reqTime > MAX_REQUEST_AGE)
|
||||||
|
{
|
||||||
|
#ifdef DATA_DEBUG
|
||||||
|
std::cerr << "RsGxsDataAccess::processrequests() Clearing Old Request Token: " << req->token;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
toClear.push_back(req->token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // END OF MUTEX.
|
||||||
|
|
||||||
|
// clear requests
|
||||||
|
std::list<uint32_t>::iterator cit;
|
||||||
|
for (cit = toClear.begin(); cit != toClear.end(); ++cit)
|
||||||
|
{
|
||||||
|
clearRequest(*cit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// process requests
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
GxsRequest* req = NULL;
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||||
|
|
||||||
|
// get the first pending request
|
||||||
|
for (it = mRequests.begin(); it != mRequests.end(); ++it)
|
||||||
|
{
|
||||||
|
GxsRequest* reqCheck = it->second;
|
||||||
|
if (reqCheck->status == GXS_REQUEST_V2_STATUS_PENDING)
|
||||||
|
{
|
||||||
|
req = reqCheck;
|
||||||
|
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // END OF MUTEX.
|
||||||
|
|
||||||
|
if (!req) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
GroupMetaReq* gmr;
|
GroupMetaReq* gmr;
|
||||||
GroupDataReq* gdr;
|
GroupDataReq* gdr;
|
||||||
@ -743,97 +817,65 @@ void RsGxsDataAccess::processRequests()
|
|||||||
GroupStatisticRequest* gsr;
|
GroupStatisticRequest* gsr;
|
||||||
ServiceStatisticRequest* ssr;
|
ServiceStatisticRequest* ssr;
|
||||||
|
|
||||||
for(it = mRequests.begin(); it != mRequests.end(); ++it)
|
|
||||||
{
|
|
||||||
|
|
||||||
GxsRequest* req = it->second;
|
|
||||||
if (req->status == GXS_REQUEST_V2_STATUS_PENDING)
|
|
||||||
{
|
|
||||||
#ifdef DATA_DEBUG
|
#ifdef DATA_DEBUG
|
||||||
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
|
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
|
||||||
<< req->status << " ReqType: " << req->reqType << " Age: "
|
<< req->status << " ReqType: " << req->reqType << " Age: "
|
||||||
<< now - req->reqTime << std::endl;
|
<< now - req->reqTime << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
|
|
||||||
|
|
||||||
/* PROCESS REQUEST! */
|
/* PROCESS REQUEST! */
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
if((gmr = dynamic_cast<GroupMetaReq*>(req)) != NULL)
|
if((gmr = dynamic_cast<GroupMetaReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getGroupSummary(gmr);
|
ok = getGroupSummary(gmr);
|
||||||
}
|
}
|
||||||
else if((gdr = dynamic_cast<GroupDataReq*>(req)) != NULL)
|
else if((gdr = dynamic_cast<GroupDataReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getGroupData(gdr);
|
ok = getGroupData(gdr);
|
||||||
}
|
}
|
||||||
else if((gir = dynamic_cast<GroupIdReq*>(req)) != NULL)
|
else if((gir = dynamic_cast<GroupIdReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getGroupList(gir);
|
ok = getGroupList(gir);
|
||||||
}
|
}
|
||||||
else if((mmr = dynamic_cast<MsgMetaReq*>(req)) != NULL)
|
else if((mmr = dynamic_cast<MsgMetaReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getMsgSummary(mmr);
|
ok = getMsgSummary(mmr);
|
||||||
}
|
}
|
||||||
else if((mdr = dynamic_cast<MsgDataReq*>(req)) != NULL)
|
else if((mdr = dynamic_cast<MsgDataReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getMsgData(mdr);
|
ok = getMsgData(mdr);
|
||||||
}
|
}
|
||||||
else if((mir = dynamic_cast<MsgIdReq*>(req)) != NULL)
|
else if((mir = dynamic_cast<MsgIdReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getMsgList(mir);
|
ok = getMsgList(mir);
|
||||||
}
|
}
|
||||||
else if((mri = dynamic_cast<MsgRelatedInfoReq*>(req)) != NULL)
|
else if((mri = dynamic_cast<MsgRelatedInfoReq*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getMsgRelatedInfo(mri);
|
ok = getMsgRelatedInfo(mri);
|
||||||
}
|
}
|
||||||
else if((gsr = dynamic_cast<GroupStatisticRequest*>(req)) != NULL)
|
else if((gsr = dynamic_cast<GroupStatisticRequest*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getGroupStatistic(gsr);
|
ok = getGroupStatistic(gsr);
|
||||||
}
|
}
|
||||||
else if((ssr = dynamic_cast<ServiceStatisticRequest*>(req)) != NULL)
|
else if((ssr = dynamic_cast<ServiceStatisticRequest*>(req)) != NULL)
|
||||||
{
|
{
|
||||||
getServiceStatistic(ssr);
|
ok = getServiceStatistic(ssr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||||
<< req->token << std::endl;
|
<< req->token << std::endl;
|
||||||
|
|
||||||
req->status = GXS_REQUEST_V2_STATUS_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL)
|
|
||||||
{
|
|
||||||
req->status = GXS_REQUEST_V2_STATUS_COMPLETE;
|
|
||||||
}
|
|
||||||
else if (req->status == GXS_REQUEST_V2_STATUS_DONE)
|
|
||||||
{
|
|
||||||
#ifdef DATA_DEBUG
|
|
||||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: "
|
|
||||||
<< req->token;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
toClear.push_back(req->token);
|
|
||||||
}
|
|
||||||
else if (now - req->reqTime > MAX_REQUEST_AGE)
|
|
||||||
{
|
|
||||||
#ifdef DATA_DEBUG
|
|
||||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Old Request Token: " << req->token;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
toClear.push_back(req->token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||||
|
if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL)
|
||||||
|
{
|
||||||
|
req->status = ok ? GXS_REQUEST_V2_STATUS_COMPLETE : GXS_REQUEST_V2_STATUS_FAILED;
|
||||||
|
}
|
||||||
} // END OF MUTEX.
|
} // END OF MUTEX.
|
||||||
|
|
||||||
for(cit = toClear.begin(); cit != toClear.end(); ++cit)
|
|
||||||
{
|
|
||||||
clearRequest(*cit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic &grpStatistic)
|
bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic &grpStatistic)
|
||||||
@ -1719,7 +1761,7 @@ bool RsGxsDataAccess::checkRequestStatus(const uint32_t& token,
|
|||||||
|
|
||||||
GxsRequest* req = locked_retrieveRequest(token);
|
GxsRequest* req = locked_retrieveRequest(token);
|
||||||
|
|
||||||
if(req == NULL)
|
if (req == NULL || req->status == GXS_REQUEST_V2_STATUS_CANCELLED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
anstype = req->ansType;
|
anstype = req->ansType;
|
||||||
|
@ -121,6 +121,7 @@ public:
|
|||||||
static const uint8_t GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE;
|
static const uint8_t GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE;
|
||||||
static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE;
|
static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE;
|
||||||
static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED.
|
static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED.
|
||||||
|
static const uint8_t GXS_REQUEST_V2_STATUS_CANCELLED;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -511,10 +511,14 @@ behind a firewall or a VPN.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="title">
|
<property name="currentIndex">
|
||||||
<string>IP blacklist</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="tabWidgetPage1" native="true">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>IP blacklist</string>
|
||||||
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="filteredIpsTable">
|
<widget class="QTableWidget" name="filteredIpsTable">
|
||||||
@ -625,14 +629,12 @@ behind a firewall or a VPN.</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
<widget class="QWidget" name="tab_3">
|
||||||
<item>
|
<attribute name="title">
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>IP whitelist</string>
|
<string>IP whitelist</string>
|
||||||
</property>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QTableWidget" name="whiteListIpsTable">
|
<widget class="QTableWidget" name="whiteListIpsTable">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
@ -681,6 +683,7 @@ behind a firewall or a VPN.</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
Loading…
Reference in New Issue
Block a user