aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/io-channel-helpers.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-10-06 15:36:54 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2022-10-12 19:22:01 +0400
commitbb06b0143b492203ab3d17640be1d819cfc33de7 (patch)
treecd0670513e91886bcc3a78cdb3adc5c6f034737e /tests/unit/io-channel-helpers.c
parent3f08376c2e1c3d3bb0b415fb1505b949d72655d4 (diff)
downloadqemu-bb06b0143b492203ab3d17640be1d819cfc33de7.zip
qemu-bb06b0143b492203ab3d17640be1d819cfc33de7.tar.gz
qemu-bb06b0143b492203ab3d17640be1d819cfc33de7.tar.bz2
tests/channel-helper: set blocking in main thread
The /io/channel/command/echo tests run the reader side and the writer side with the same underlying command channel. Setting the blocking mode of the fd/handles while the other end is already reading/writing may create issues (deadlock in win32 when earlier attempt of this series were using SetNamedPipeHandleState). Let's just do it before spawning the threads to avoid further concurrency issues. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221006113657.2656108-4-marcandre.lureau@redhat.com>
Diffstat (limited to 'tests/unit/io-channel-helpers.c')
-rw-r--r--tests/unit/io-channel-helpers.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/unit/io-channel-helpers.c b/tests/unit/io-channel-helpers.c
index ff156ed..c0799c2 100644
--- a/tests/unit/io-channel-helpers.c
+++ b/tests/unit/io-channel-helpers.c
@@ -25,7 +25,6 @@
struct QIOChannelTest {
QIOChannel *src;
QIOChannel *dst;
- bool blocking;
size_t len;
size_t niov;
char *input;
@@ -42,8 +41,6 @@ static gpointer test_io_thread_writer(gpointer opaque)
{
QIOChannelTest *data = opaque;
- qio_channel_set_blocking(data->src, data->blocking, NULL);
-
qio_channel_writev_all(data->src,
data->inputv,
data->niov,
@@ -58,8 +55,6 @@ static gpointer test_io_thread_reader(gpointer opaque)
{
QIOChannelTest *data = opaque;
- qio_channel_set_blocking(data->dst, data->blocking, NULL);
-
qio_channel_readv_all(data->dst,
data->outputv,
data->niov,
@@ -113,7 +108,9 @@ void qio_channel_test_run_threads(QIOChannelTest *test,
test->src = src;
test->dst = dst;
- test->blocking = blocking;
+
+ qio_channel_set_blocking(test->dst, blocking, NULL);
+ qio_channel_set_blocking(test->src, blocking, NULL);
reader = g_thread_new("reader",
test_io_thread_reader,