Avoid multiple ping uploads in flight by launching the next step after upload is done

This commit is contained in:
Jan-Erik Rediger 2022-03-16 17:22:17 +01:00 коммит произвёл Jan-Erik Rediger
Родитель 31aec35ae5
Коммит d1f4821d0a
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -159,7 +159,16 @@ public class HttpPingUploader {
body.append(contentsOf: request.body) body.append(contentsOf: request.body)
self.upload(path: request.path, data: body, headers: request.headers) { result in self.upload(path: request.path, data: body, headers: request.headers) { result in
gleanProcessPingUploadResponse(request.documentId, result) gleanProcessPingUploadResponse(request.documentId, result)
// launch a new iteration.
Dispatchers.shared.launchAsync {
HttpPingUploader(configuration: self.config, testingMode: self.testingMode).process()
} }
}
// we don't want to launch multiple uploads at once.
// if the upload finishes, we going to launch the next one.
return
case .wait(let time): case .wait(let time):
sleep(UInt32(time) / 1000) sleep(UInt32(time) / 1000)
continue continue