fix(mt): publish filled input before job creation

The Rust MT stream scheduler now copies input into the reusable round buffer
through its local projection and publishes the final filled count when the
outer call returns.  Job creation, however, is a C callback invoked during that
same scheduler call.  It still inspected `mtctx->inBuff.filled` while preparing
the job, so the count lagged behind the bytes Rust had just copied and the
existing preparation assertion fired in the multiple-file CLI path.

Publish the callback's `srcSize` into the C context before constructing the job
projection.  This restores the ordering of the former C copy callback: the
context count is current before job preparation, while the existing end-of-call
result publication remains available for paths that do not create a job.

Test Plan:
- `cc -fsyntax-only -Werror=incompatible-pointer-types -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dict -Ilib/legacy lib/compress/zstdmt_compress.c` -- passed
- `git diff --check` and `git diff --cached --check` -- passed
- `make -j1 -C tests test` reproduced the pre-fix assertion in
  `ZSTDMT_prepareCompressionJob`; the capped full-suite rerun is pending
This commit is contained in:
2026-07-20 15:15:17 +02:00
parent fbbb0c5801
commit ab9e2243ed
+5
View File
@@ -2723,6 +2723,11 @@ static size_t ZSTDMT_createCompressionJob(void* opaque, size_t srcSize, unsigned
{
ZSTDMT_CCtx* const mtctx = (ZSTDMT_CCtx*)opaque;
ZSTD_EndDirective const endOp = (ZSTD_EndDirective)end;
/* Rust fills the reusable input range in its local projection before
* calling this C-owned job-construction callback. Publish that count
* before the callback prepares a job and checks the C context. */
assert(srcSize <= mtctx->inBuff.buffer.capacity);
mtctx->inBuff.filled = srcSize;
ZSTDMT_RustCreateJobProjection const projection = {
mtctx->doneJobID,
mtctx->nextJobID,