mirror of
https://github.com/apple/swift-nio-extras
synced 2026-11-24 04:37:58 +00:00
Motivation: The HTTPResumableUpload type is non-sendable and bound to a particular event loop. It holds a ref to a HTTPResumableUploadHandler which is also non-sendable and bound to a particular event loop which may be different to the event loop of the upload. This should not be possible: if the event loops aren't guaranteed to be the same then the upload can't possibly hold a handler as it must necessarily cross an isolation domain. The sendable view of the uploads are also held in a dictionary protected by a mutex but also provide access to the loop bound holding the upload. This makes it a little too easy to accidentally use the loop bound value from the wrong event loop which will lead to a runtime crash. Modifications: - Add a sendable view to the HTTPResumableUploadHandler which dispatches work to the correct event loop - Replace occurrences of HTTPResumableUploadHandler with its sendable view in the HTTPResumableUpload - Extend the sendable view of HTTPResumableUpload and audit calls using the loop bound value - Add a test for multi-thread multi-chunk uploads Result: Can do multi-chunk multi-thread uploads without runtime crashes