You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When backsource file with unknown content length, the remote peer will hang if the local peer didn't sync content length and total pieces with remote peer before sending the last piece.
Suppose file size=128MB, pieceSize=4MB, totalPieces=32. the local peer will send 32 pieces to remote peer, and total pieces=-1 in the last piece.
This is due to the last piece(31) is sent before the content length is generated, and the remote peer will wait infinitiy since it didn't get the content length info.
Bug report:
When backsource file with unknown content length, the remote peer will hang if the local peer didn't sync content length and total pieces with remote peer before sending the last piece.
Suppose file size=128MB, pieceSize=4MB, totalPieces=32. the local peer will send 32 pieces to remote peer, and total pieces=-1 in the last piece.
This is due to the last piece(31) is sent before the content length is generated, and the remote peer will wait infinitiy since it didn't get the content length info.
Root cause in code:
The last piece(32) size can be zero when file size aligns with piece size, so it didn't count into total pieces which is fine.
https://github.com/dragonflyoss/Dragonfly2/blob/75d624260f55578fc6abbd1a7643d02fe20a13c3/client/daemon/peer/piece_manager.go#L556-L563
But when content length is updated, the real last piece(31) can already be sent, causing content length info missed.
https://github.com/dragonflyoss/Dragonfly2/blob/75d624260f55578fc6abbd1a7643d02fe20a13c3/client/daemon/peer/piece_manager.go#L597-L602
Expected behavior:
How to reproduce it:
Add a time.Sleep before updating content length, and download a 128MB file.
https://github.com/dragonflyoss/Dragonfly2/blob/75d624260f55578fc6abbd1a7643d02fe20a13c3/client/daemon/peer/piece_manager.go#L597-L602
Environment:
uname -a
):The text was updated successfully, but these errors were encountered: