[LTP] [PATCH v3] aio_cancel_7-1: Write into a socket
Martin Doucha
mdoucha@suse.cz
Mon Sep 1 18:19:17 CEST 2025
On 25. 08. 25 5:07, Li Wang wrote:
> We need to update the code comments as well:
>
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> * Copyright (c) 2004, Bull SA. All rights reserved.
> * Copyright (c) Linux Test Project, 2025
> */
>
> /*
> * Assertion:
> * aio_cancel() shall return AIO_NOTCANCELED if at least one requested
> * operation cannot be canceled because it is already in progress.
> *
> * Method:
> * 1. Queue multiple aio_write() requests to a given file descriptor.
> * 2. Call aio_cancel() to attempt canceling all operations.
> * 3. Check each operation's result using aio_error():
> * - If aio_error() returns EINPROGRESS but aio_cancel() did not
> return
> * AIO_NOTCANCELED, the test FAILS.
> * - If aio_error() returns 0 (success) and aio_cancel() returned
> * AIO_NOTCANCELED, the test PASSES.
> * - Otherwise, the test result is UNRESOLVED.
> */
Hmm, yes. But now that I read the test description again, I notice that
the additional check for aio_error() == ECANCELED does not fit the
intended scenario. The test should wait until aiocb[2] enters the
EINPROGRESS state before before calling aio_cancel(). I'll rewrite that
and send v4.
> +static void cleanup(void)
> +{
> + int i;
> +
> + close(fds[1]);
> + close(fds[0]);
> +
> + for (i = 0; i < BUF_NB; i++)
> + free((void *)aiocb[i]->aio_buf);
>
>
> Agree, and maybe do something further:
>
> for (i = 0; i < BUF_NB; i++) {
> if (aiocb[i]) {
> if (aiocb[i]->aio_buf)
> free((void *)aiocb[i]->aio_buf);
> free(aiocb[i]);
> aiocb[i] = NULL;
> }
> }
>
I forgot about the the aiocbs being dynamically allocated as well while
writing the cleanup() function. But the better solution would be to
remove the calloc()s entirely and have the aiocb array statically allocated.
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
More information about the ltp
mailing list