mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[cdc_rsync] Fix issue in UnzstdStream (#59)
Fixes an issue in UnzstdStream where the Read() method always tries to read new input data if no input data is available, instead of first trying to uncompress. Since zstd maintains internal buffers, uncompression might succeed even without reading more input, so this is faster. This bug can lead to pipeline stalls in cdc_rsync.
This commit is contained in:
@@ -36,8 +36,13 @@ class ZstdStream {
|
||||
// Sends the given |data| to the compressor.
|
||||
absl::Status Write(const void* data, size_t size) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Flushes all remaining data and sends the compressed data to the socket.
|
||||
absl::Status Flush() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
// Finishes the stream and flushes all remaining data.
|
||||
absl::Status Finish() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Flushes internal buffers if no new data is written for longer than this
|
||||
// time. This makes sure that no data is stuck in the pipeline if no new input
|
||||
// is available. Default is 500 ms.
|
||||
void AutoFlushAfter(absl::Duration dur) { auto_flush_period_ = dur; }
|
||||
|
||||
private:
|
||||
// Initializes the compressor and related data.
|
||||
@@ -58,6 +63,8 @@ class ZstdStream {
|
||||
bool last_chunk_sent_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
absl::Status status_ ABSL_GUARDED_BY(mutex_);
|
||||
std::thread compressor_thread_;
|
||||
|
||||
absl::Duration auto_flush_period_;
|
||||
};
|
||||
|
||||
} // namespace cdc_ft
|
||||
|
||||
Reference in New Issue
Block a user