Skip to content

Commit

Permalink
修复mono runtime下调用高级下载 Pause & Resume 接口偶发下载失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnnqin committed Nov 17, 2022
1 parent c2780e5 commit b79fb5e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ internal void Download()
}
// concurrent download
ConcurrentGetObject(result.crc64ecma);
}
}

},

Expand Down Expand Up @@ -462,8 +462,9 @@ private void ConcurrentGetObject(string crc64ecma)
return;
}
// 对客户端异常, 全部都重试
if (clientEx != null)
if (clientEx != null) {
gClientExp = clientEx;
}
resetEvent.Set();
}
);
Expand Down Expand Up @@ -528,7 +529,7 @@ 超出 singleTaskTimeoutMs 时,全部清理掉进入下一轮重试
}
}
return;
}
}
// 预期每个分块都下载完成了, 开始顺序合并
FileMode fileMode = FileMode.OpenOrCreate;
FileInfo localFileInfo = new FileInfo(localDir + localFileName);
Expand Down Expand Up @@ -672,18 +673,10 @@ private void RealCancle()
// 停止可能进行中的Head请求
cosXmlServer.Cancel(headObjectRequest);
// 停止可能进行中的下载线程
Interlocked.Decrement(ref activeTasks);
foreach (GetObjectRequest subGetObjectRequest in getObjectRequestsList) {
cosXmlServer.Cancel(subGetObjectRequest);
}
activeTasks = 0;
/*
// wait for tasks to finish
while (activeTasks > 0)
{
Thread.Sleep(100);
}
*/
getObjectRequestsList.Clear();
}

private void Clear()
Expand Down Expand Up @@ -711,7 +704,7 @@ public override void Pause()
{
//exit download
lock (syncExit)
{
{
isExit = true;
}
//cancle request
Expand Down

0 comments on commit b79fb5e

Please sign in to comment.