fix(mt): keep projected job snapshots under mutex
The Rust-owned frame-progression ring scan consumes ZSTDMT_jobProjection through ZSTDMT_projectJob. That callback previously copied counters under job_mutex but read source and prefix metadata after unlocking. Keep the complete projection in one mutex-protected snapshot, matching the original ZSTDMT_getFrameProgression access pattern without moving descriptor or synchronization ownership out of C. Test Plan: - `rustfmt --check --edition 2021 rust/src/zstdmt_compress.rs` -- passed. - `git diff --check` and `git diff --cached --check` -- passed. - Static inspection only; no cargo, make, native binaries, tests, fuzzers, or heavyweight commands were run.
This commit is contained in:
@@ -1703,12 +1703,12 @@ static void ZSTDMT_projectJob(void* opaque, unsigned jobID,
|
||||
ZSTD_pthread_mutex_lock(&job->job_mutex);
|
||||
projection->consumed = job->consumed;
|
||||
projection->cSize = job->cSize;
|
||||
projection->dstFlushed = job->dstFlushed;
|
||||
ZSTD_pthread_mutex_unlock(&job->job_mutex);
|
||||
projection->srcStart = job->src.start;
|
||||
projection->srcSize = job->src.size;
|
||||
projection->prefixStart = job->prefix.start;
|
||||
projection->prefixSize = job->prefix.size;
|
||||
projection->dstFlushed = job->dstFlushed;
|
||||
ZSTD_pthread_mutex_unlock(&job->job_mutex);
|
||||
}
|
||||
|
||||
static void ZSTDMT_freeJobsTable(ZSTDMT_jobDescription* jobTable, U32 nbJobs, ZSTD_customMem cMem)
|
||||
|
||||
@@ -664,8 +664,8 @@ pub type ZSTDMT_bufferGetFn = unsafe extern "C" fn(*mut c_void) -> ZstdMtBuffer;
|
||||
|
||||
/// Scalar snapshot of one C-owned job descriptor.
|
||||
///
|
||||
/// The C adapter fills this projection while holding the descriptor mutex.
|
||||
/// Rust owns only the ring-scan decisions below; the descriptor layout,
|
||||
/// The C adapter fills the complete projection while holding the descriptor
|
||||
/// mutex. Rust owns only the ring-scan decisions below; the descriptor layout,
|
||||
/// synchronization objects, and all pointer ownership stay in C.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
|
||||
Reference in New Issue
Block a user