Skip to content

Commit

Permalink
Merge pull request #109 from NordicSemiconductor/breaking-loop
Browse files Browse the repository at this point in the history
Cancelling upload on too many retries
  • Loading branch information
philips77 committed Aug 16, 2023
2 parents 7485509 + 10372eb commit 8d2686d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ abstract class Uploader(
// chunk. We need to resend the chunk at the offset
// requested by the device.
log.warn("Chunk with offset ${chunk.offset} has been lost (expected offset=${chunk.offset + chunk.data.size}, received=${response.off})")
val fails = failureDirectoryMutex.withLock {
val fails = (failureDirectory[chunk.offset] ?: 0) + 1
failureDirectory[chunk.offset] = fails
fails
}
if (fails >= MAX_CHUNK_FAILURES) {
throw McuMgrException("Chunk with offset ${chunk.offset} has not been acknowledged too many times")
}
failures.send(newChunk(response.off))
} else {
// Success, update the progress.
Expand Down

0 comments on commit 8d2686d

Please sign in to comment.