feat: when send piece error drop out_stream_tx (#715)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2024-09-04 00:13:35 +08:00 committed by GitHub
parent 02481a71fc
commit 917f950cd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -671,20 +671,27 @@ impl DfdaemonUpload for DfdaemonUploadServerHandler {
// Send the piece metadata to the stream. // Send the piece metadata to the stream.
if piece.is_finished() { if piece.is_finished() {
out_stream_tx match out_stream_tx
.send(Ok(SyncPiecesResponse { .send(Ok(SyncPiecesResponse {
number: piece.number, number: piece.number,
offset: piece.offset, offset: piece.offset,
length: piece.length, length: piece.length,
})) }))
.await .await
.unwrap_or_else(|err| { {
Ok(_) => {
info!("send piece metadata {}-{}", task_id, piece.number);
}
Err(err) => {
error!( error!(
"send finished piece {}-{} to stream: {}", "send piece metadata {}-{} to stream: {}",
task_id, interested_piece_number, err task_id, interested_piece_number, err
); );
});
info!("send piece metadata {}-{}", task_id, piece.number); drop(out_stream_tx);
return;
}
}
// Add the finished piece number to the finished piece numbers. // Add the finished piece number to the finished piece numbers.
finished_piece_numbers.push(piece.number); finished_piece_numbers.push(piece.number);