Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for enqueue/dequeue errors #1120

Merged
merged 4 commits into from
Jan 12, 2024
Merged

Conversation

pcercuei
Copy link
Contributor

@pcercuei pcercuei commented Jan 12, 2024

Given that the IIOD protocol has a single command for enqueue + dequeue, in case of an error we need to have a way to know which operation failed, so that the client can retry without having to tear down the whole IIO buffer.

Fixes #1109.

@pcercuei
Copy link
Contributor Author

The Codacy report looks completely bogus to me, or do I not know C?

We need one mask to know whether a block has been enqueued (bit set) or
dequeued (bit clear) from the kernel interface, and one flag to know
whether the libiio application already tried to enqueue or dequeue the
block.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
@pcercuei pcercuei force-pushed the pcercuei/handle-retry-dequeue branch 2 times, most recently from afbf8b1 to a58629c Compare January 12, 2024 09:59
The IIOD_OP_TRANSFER_BLOCK command would atomically enqueue then dequeue
the given block. The problem with that, was that on error it was not
possible to know which of the two operations was the cause of the error.

Change this by encoding the return value in a way that we can deduce
which of the two operations failed.

Then, if the enqueue failed, the block will be marked as not enqueued,
and can be enqueued again. If the dequeue failed, the block is still
marked as enqueued, and the next dequeue attempt will see the use of the
IIOD_OP_RETRY_DEQUEUE_BLOCK command, which will only dequeue the block.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
When handling the IIOD_OP_TRANSFER_BLOCK, we need a way to tell the
client which one of the two operations (enqueue or dequeue) failed.

Do that by shifting left the error code by 16 bits if the enqueue
failed, and by not shifting the value if the dequeue failed.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
During a previous IIOD_OP_TRANSFER_BLOCK command, if the enqueue
succeeded but dequeue failed, the client cannot send the same command
again, as it would try to enqueue again. Instead, it will send a
IIOD_RETRY_DEQUEUE_BLOCK, which will only attempt to dequeue the block.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
@pcercuei pcercuei force-pushed the pcercuei/handle-retry-dequeue branch from a58629c to b6576dc Compare January 12, 2024 10:12
@pcercuei pcercuei merged commit fcfb5d1 into main Jan 12, 2024
24 checks passed
@pcercuei pcercuei deleted the pcercuei/handle-retry-dequeue branch January 12, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot recover when iio_block_dequeue() timeouts
2 participants