From: Yonatan Komornik <11005061+yoniko@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:28:32 +0000 (-0700) Subject: Fix AsyncIO reading seed queueing (#3940) X-Git-Tag: v1.5.6^2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edab9eed66f02c7c3c8be849f22f20ffbd04976b;p=thirdparty%2Fzstd.git Fix AsyncIO reading seed queueing (#3940) Fixes a bug in AsyncIO where we queue reads after opening a file so our queue will always be saturated (or as saturated as possible). Previous code was looping up to `availableJobsCount` not realizing `availableJobsCount` was also decreasing in each iteration, so instead of queueing 10 jobs we'd queue 5 (and instead of 2 we'd queue 1). This PR fixes the loop to queue as long as `availableJobsCount` is not 0. --- diff --git a/programs/fileio_asyncio.c b/programs/fileio_asyncio.c index 5f7bd4a4c..ae6db69e0 100644 --- a/programs/fileio_asyncio.c +++ b/programs/fileio_asyncio.c @@ -514,8 +514,7 @@ static void AIO_ReadPool_enqueueRead(ReadPoolCtx_t* ctx) { } static void AIO_ReadPool_startReading(ReadPoolCtx_t* ctx) { - int i; - for (i = 0; i < ctx->base.availableJobsCount; i++) { + while(ctx->base.availableJobsCount) { AIO_ReadPool_enqueueRead(ctx); } }