From 0e5d6327f3abb8d582cbc2e444a23ef0dc6a64c7 Mon Sep 17 00:00:00 2001 From: Wang guang Date: Mon, 3 Apr 2017 12:05:21 +0100 Subject: [PATCH] io: fix incoming client socket initialization The channel socket was initialized manually, but forgot to set QIO_CHANNEL_FEATURE_SHUTDOWN. Thus, the colo_process_incoming_thread would hang at recvmsg. This patch just call qio_channel_socket_new to get channel, Which set QIO_CHANNEL_FEATURE_SHUTDOWN already. Signed-off-by: Wang Guang Signed-off-by: zhanghailiang Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- io/channel-socket.c | 8 +------- tests/test-io-channel-socket.c | 8 ++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index f546c6830e..64b36f58be 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -331,16 +331,10 @@ qio_channel_socket_accept(QIOChannelSocket *ioc, { QIOChannelSocket *cioc; - cioc = QIO_CHANNEL_SOCKET(object_new(TYPE_QIO_CHANNEL_SOCKET)); - cioc->fd = -1; + cioc = qio_channel_socket_new(); cioc->remoteAddrLen = sizeof(ioc->remoteAddr); cioc->localAddrLen = sizeof(ioc->localAddr); -#ifdef WIN32 - QIO_CHANNEL(cioc)->event = CreateEvent(NULL, FALSE, FALSE, NULL); -#endif - - retry: trace_qio_channel_socket_accept(ioc); cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr, diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c index aaa9116fb7..c5c131479c 100644 --- a/tests/test-io-channel-socket.c +++ b/tests/test-io-channel-socket.c @@ -234,6 +234,8 @@ static void test_io_channel(bool async, qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); + g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); + g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); @@ -248,6 +250,8 @@ static void test_io_channel(bool async, qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); + g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); + g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); @@ -262,6 +266,8 @@ static void test_io_channel(bool async, qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); + g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); + g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); @@ -276,6 +282,8 @@ static void test_io_channel(bool async, qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); + g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); + g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); -- 2.11.4.GIT