From: Lars-Peter Clausen Date: Fri, 6 Jul 2012 21:23:30 +0000 (+0200) Subject: sr: demodevice: Make read channel non-blocking X-Git-Tag: dsupstream~871 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=e6e8f8e0531805a9215eebcb0d4d270a5afa6a8d;hp=93b03d091abb947fdf78e57f864313571fb903ab;p=libsigrok.git sr: demodevice: Make read channel non-blocking Both pipe channels are currently configured as blocking. We read from the pipe in receive_data. Since the channel is configured as blocking we'll block in receive_data until all data has been received. receive_data will be called from the mainloop, so as consequence the mainloop will be blocked until the demo device has finished sampling. This is not so much of a problem if we are sampling in blocking mode (using sr_session_run()) and the demo device is the only device in the session, but it will fail badly for all other configurations (e.g. multiple devices or async sampling). Signed-off-by: Lars-Peter Clausen --- diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 0cd23e3c..91f105f3 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -440,6 +440,8 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) ctx->channels[0] = g_io_channel_unix_new(ctx->pipe_fds[0]); ctx->channels[1] = g_io_channel_unix_new(ctx->pipe_fds[1]); + g_io_channel_set_flags(ctx->channels[0], G_IO_FLAG_NONBLOCK, NULL); + /* Set channel encoding to binary (default is UTF-8). */ g_io_channel_set_encoding(ctx->channels[0], NULL, NULL); g_io_channel_set_encoding(ctx->channels[1], NULL, NULL);