Files
swift-nio-extras/Sources
George Barnett 1c90641b02 Fix sendability issue in NIOResumableUpload (#299)
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
2025-12-09 09:24:30 +00:00
..
2025-01-14 11:24:08 +00:00
2025-01-14 11:24:08 +00:00