return 0;
}
-static int __precheck_request(dp_request_fmt *request, int agentid)
+static int __precheck_request(dp_client_slots_fmt* slot, dp_request_fmt *request, int agentid)
{
if (request == NULL) {
TRACE_ERROR("null-check req_id:%d", agentid);
return -1;
}
- if (dp_is_alive_download(agentid) == 0) {
- TRACE_ERROR("alive-check req_id:%d", agentid);
- return -1;
- }
+ dp_client_fmt *client = &slot->client;
- if (request->id < 0 || (request->agent_id != agentid)) {
- TRACE_ERROR("id-check request_id:%d agent_id:%d req_id:%d",
- request->id, request->agent_id, agentid);
- return -1;
+ for (dp_request_fmt *req = client->requests; req; req = req->next) {
+ if (req == request) {
+ if (request->id < 0 || (request->agent_id != agentid)) {
+ TRACE_ERROR("id-check request_id:%d agent_id:%d req_id:%d",
+ request->id, request->agent_id, agentid);
+ return -1;
+ }
+ return 0;
+ }
}
- return 0;
+ return -1;
}
static int __set_file_permission_to_client(dp_client_slots_fmt *slot, dp_request_fmt *request, char *saved_path)
return ;
}
CLIENT_MUTEX_LOCK(&slot->mutex);
- if (__precheck_request(request, info->download_id) < 0) {
+ if (__precheck_request(slot, request, info->download_id) < 0) {
TRACE_ERROR("error request agent_id:%d", info->download_id);
if (dp_cancel_agent_download(info->download_id) < 0)
TRACE_ERROR("failed to call cancel_download(%d)", info->download_id);
return ;
}
CLIENT_MUTEX_LOCK(&slot->mutex);
- if (__precheck_request(request, info->download_id) < 0) {
+ if (__precheck_request(slot, request, info->download_id) < 0) {
TRACE_ERROR("error request agent_id:%d", info->download_id);
if (dp_cancel_agent_download(info->download_id) < 0)
TRACE_ERROR("failed to call cancel_download(%d)", info->download_id);
return ;
}
*/
- if (__precheck_request(request, download_id) < 0) {
+ if (__precheck_request(slot, request, download_id) < 0) {
TRACE_ERROR("error request agent_id:%d", download_id);
if (dp_cancel_agent_download(download_id) < 0)
TRACE_ERROR("failed to call cancel_download(%d)", download_id);