[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 3/6] tests/channel-helper: set blocking in main thread
From: |
marcandre . lureau |
Subject: |
[PATCH v4 3/6] tests/channel-helper: set blocking in main thread |
Date: |
Thu, 6 Oct 2022 15:36:54 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
tests/unit/io-channel-helpers.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tests/unit/io-channel-helpers.c b/tests/unit/io-channel-helpers.c
index ff156ed3c4..c0799c21c2 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,
--
2.37.3
- [PATCH v4 0/6] io/command: implement portable spawn, marcandre . lureau, 2022/10/06
- [PATCH v4 1/6] osdep: make readv_writev() work with partial read/write, marcandre . lureau, 2022/10/06
- [PATCH v4 2/6] util: make do_send_recv work with partial send/recv, marcandre . lureau, 2022/10/06
- [PATCH v4 5/6] io/command: implement support for win32, marcandre . lureau, 2022/10/06
- [PATCH v4 3/6] tests/channel-helper: set blocking in main thread,
marcandre . lureau <=
- [PATCH v4 4/6] io/command: use glib GSpawn, instead of open-coding fork/exec, marcandre . lureau, 2022/10/06
- [PATCH v4 6/6] tests/unit: make test-io-channel-command work on win32, marcandre . lureau, 2022/10/06