Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nunojsa committed Feb 12, 2025
1 parent e4c2a48 commit 75b7010
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions iiod-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,9 @@ void iiod_client_free_block(struct iio_block_pdata *block)
/* Cancel any I/O going on. This means we must send the block free
* command through the main I/O as the block's I/O stream is
* disrupted. */
fprintf(stderr, "Canceling block %d\n", block->idx);
iiod_io_cancel(block->io);
fprintf(stderr, "Done canceling block %d\n", block->idx);
iiod_io_unref(block->io);

io = iiod_responder_get_default_io(client->responder);
Expand Down
11 changes: 9 additions & 2 deletions iiod-responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ static ssize_t iiod_rw_all(struct iiod_responder *priv,

if (is_read)
ret = priv->ops->read(priv->d, curr, nb);
else
else {
printf("Write %zd bytes, req(%zu)\n", curr->size, bytes);
ret = priv->ops->write(priv->d, curr, nb);
printf("Done Write %zd bytes\n", curr->size);
}
if (ret <= 0)
return ret;

Expand Down Expand Up @@ -294,7 +297,9 @@ static int iiod_responder_reader_worker(struct iiod_responder *priv)
/* We received a response, but have no client waiting
* for it, so drop it. */
iio_mutex_unlock(priv->lock);
fprintf(stderr, "Discard data(%d)\n", cmd.code);
iiod_discard_data(priv, cmd.code);
fprintf(stderr, "Data Discarded(%d)\n", cmd.code);
iio_mutex_lock(priv->lock);
continue;
}
Expand All @@ -310,8 +315,10 @@ static int iiod_responder_reader_worker(struct iiod_responder *priv)
ret = iiod_rw_all(priv, NULL, io->r_io.buf,
io->r_io.nb_buf, cmd.code, true);

if (ret > 0 && (size_t) ret < (size_t) cmd.code)
if (ret > 0 && (size_t) ret < (size_t) cmd.code) {
fprintf(stderr, "Discard data now(%zd)\n", cmd.code - ret);
iiod_discard_data(priv, cmd.code - ret);
}

iio_mutex_lock(priv->lock);

Expand Down
3 changes: 3 additions & 0 deletions iiod/responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,11 @@ static int buffer_dequeue_block(void *priv, void *d)
ret = data.size;
}


out_send_response:
printf("Sending response (%d)\n", entry->idx);
iiod_io_send_response(entry->io, ret, &data, nb_data);
printf("Done Sending response (%d)\n", entry->idx);
return 0;
}

Expand Down
10 changes: 8 additions & 2 deletions stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <errno.h>
#include <iio/iio-debug.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

struct iio_stream {
Expand Down Expand Up @@ -73,9 +74,14 @@ void iio_stream_destroy(struct iio_stream *stream)
{
size_t i;

for (i = 0; i < stream->nb_blocks; i++)
if (stream->blocks[i])
for (i = 0; i < stream->nb_blocks; i++) {
if (stream->blocks[i]) {
//iio_block_dequeue(stream->blocks[i], false);
fprintf(stderr, "destroy block %zd\n", i);
iio_block_destroy(stream->blocks[i]);
fprintf(stderr, "done destroy block %zd\n", i);
}
}
free(stream->blocks);
free(stream);
}
Expand Down
18 changes: 14 additions & 4 deletions utils/iio_rwdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ static int exit_code = EXIT_FAILURE;
static void quit_all(int sig)
{
exit_code = sig;
/*
* If the main function is stuck waiting for data it will not abort. If the
* user presses Ctrl+C a second time we abort without cleaning up.
*/
if (!app_running)
exit(sig);

app_running = false;
if (buffer)
iio_buffer_cancel(buffer);
}

#ifdef _WIN32
Expand Down Expand Up @@ -138,9 +143,11 @@ static void * sig_handler_thd(void *data)
/* Blocks until one of the termination signals is received */
do {
ret = sigwait(mask, &sig);
} while (ret == EINTR);
if (ret == EINTR)
continue;

quit_all(ret);
quit_all(ret);
} while (1);

return NULL;
}
Expand Down Expand Up @@ -541,10 +548,13 @@ int main(int argc, char **argv)
}

err_destroy_stream:
fprintf(stderr, "iio_stream_destroy\n");
iio_stream_destroy(stream);
err_destroy_buffer:
fprintf(stderr, "iio_buffer_destroy\n");
iio_buffer_destroy(buffer);
err_free_mask:
fprintf(stderr, "iio_channels_mask_destroy\n");
iio_channels_mask_destroy(mask);
err_free_ctx:
if (ctx)
Expand Down

0 comments on commit 75b7010

Please sign in to comment.