Skip to content

Commit

Permalink
iiod: Add support for IIOD_OP_RETRY_DEQUEUE_BLOCK command
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pcercuei committed Jan 12, 2024
1 parent 2b160e1 commit 0c08ffd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions iiod/responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,41 @@ static void handle_transfer_block(struct parser_pdata *pdata,
iiod_io_send_response_code(block_entry->io, ret);
}

static void handle_retry_dequeue_block(struct parser_pdata *pdata,
const struct iiod_command *cmd,
struct iiod_command_data *cmd_data)
{
struct buffer_entry *entry;
struct block_entry *block_entry;
struct iio_block *block;
struct iio_buffer *buf;
int ret;

buf = get_iio_buffer(pdata, cmd, &entry);
ret = iio_err(buf);
if (ret) {
IIO_PERROR(ret, "handle_transfer_block: Could not find IIO buffer");
return;
}

block = get_iio_block(pdata, entry, cmd, &block_entry);
ret = iio_err(block);
if (ret) {
IIO_PERROR(ret, "handle_transfer_block: Could not find IIO block");
return;
}

ret = iio_task_enqueue_autoclear(entry->dequeue_task, block_entry);
if (ret)
goto out_send_response;

/* The return code and/or data will be sent from the task handler. */
return;

out_send_response:
iiod_io_send_response_code(block_entry->io, ret);
}

static int evstream_read(void *priv, void *d)
{
struct evstream_entry *entry = priv;
Expand Down Expand Up @@ -982,6 +1017,7 @@ static const iiod_opcode_fn iiod_op_functions[] = {
[IIOD_OP_FREE_BLOCK] = handle_free_block,
[IIOD_OP_TRANSFER_BLOCK] = handle_transfer_block,
[IIOD_OP_ENQUEUE_BLOCK_CYCLIC] = handle_transfer_block,
[IIOD_OP_RETRY_DEQUEUE_BLOCK] = handle_retry_dequeue_block,

[IIOD_OP_CREATE_EVSTREAM] = handle_create_evstream,
[IIOD_OP_FREE_EVSTREAM] = handle_free_evstream,
Expand Down

0 comments on commit 0c08ffd

Please sign in to comment.