Skip to content

Commit

Permalink
iiod: Identify blocks using command code
Browse files Browse the repository at this point in the history
Instead of using the client ID, use the block number encoded in the
command code.

This makes it possible to access the blocks through a different
iiod-client instance.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Jan 31, 2024
1 parent e69bfe6 commit 5a9be31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion iiod/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct block_entry {
struct iio_block *block;
struct iiod_io *io;
uint64_t bytes_used;
uint16_t client_id;
uint16_t idx;
bool cyclic;
};

Expand Down
4 changes: 2 additions & 2 deletions iiod/responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static struct iio_block * get_iio_block(struct parser_pdata *pdata,
iio_mutex_lock(entry_buf->lock);

SLIST_FOREACH(entry, &entry_buf->blocklist, entry) {
if (entry->client_id == cmd->client_id) {
if (entry->idx == cmd->code >> 16) {
block = entry->block;
break;
}
Expand Down Expand Up @@ -670,7 +670,7 @@ static void handle_create_block(struct parser_pdata *pdata,

entry->block = block;
entry->io = io;
entry->client_id = cmd->client_id;
entry->idx = cmd->code >> 16;

/* Keep a reference to the iiod_io until the block is freed. */
iiod_io_ref(io);
Expand Down

0 comments on commit 5a9be31

Please sign in to comment.