Skip to content

Commit

Permalink
TCP source: Return the count of copied bytes into buffer
Browse files Browse the repository at this point in the history
The real number of added bytes is what get copied into buffer,
not the bytes count we get from the socket.
  • Loading branch information
AmmarAbouZor committed Feb 14, 2025
1 parent 6b1a612 commit fcdbb1c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions application/apps/indexer/sources/src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ impl ByteSource for TcpSource {
}
};
}
self.buffer.copy_from_slice(&self.tmp_buffer[..len]);
// The real number of added bytes is what get copied into buffer,
// not the bytes count we get from the socket.
let added = self.buffer.copy_from_slice(&self.tmp_buffer[..len]);
let available_bytes = self.buffer.len();
return Ok(Some(ReloadInfo::new(len, available_bytes, 0, None)));
return Ok(Some(ReloadInfo::new(added, available_bytes, 0, None)));
}
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
continue;
Expand Down

0 comments on commit fcdbb1c

Please sign in to comment.