static void test_io_channel_setup_async(SocketAddress *listen_addr,

                                        SocketAddress *connect_addr,

                                        QIOChannel **src,

                                        QIOChannel **dst)

{

    QIOChannelSocket *lioc;

    struct TestIOChannelData data;



    data.loop = g_main_loop_new(g_main_context_default(),

                                TRUE);



    lioc = qio_channel_socket_new();

    qio_channel_socket_listen_async(

        lioc, listen_addr,

        test_io_channel_complete, &data, NULL);



    g_main_loop_run(data.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!data.err);



    if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) {

        SocketAddress *laddr = qio_channel_socket_get_local_address(

            lioc, &error_abort);



        g_free(connect_addr->u.inet.data->port);

        connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);



        qapi_free_SocketAddress(laddr);

    }



    *src = QIO_CHANNEL(qio_channel_socket_new());



    qio_channel_socket_connect_async(

        QIO_CHANNEL_SOCKET(*src), connect_addr,

        test_io_channel_complete, &data, NULL);



    g_main_loop_run(data.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!data.err);



    qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);

    *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));

    g_assert(*dst);



    qio_channel_set_delay(*src, false);

    test_io_channel_set_socket_bufs(*src, *dst);



    object_unref(OBJECT(lioc));



    g_main_loop_unref(data.loop);

}

static void test_io_channel_setup_async(SocketAddress *listen_addr,

                                        SocketAddress *connect_addr,

                                        QIOChannel **src,

                                        QIOChannel **dst)

{

    QIOChannelSocket *lioc;

    struct TestIOChannelData data;



    data.loop = g_main_loop_new(g_main_context_default(),

                                TRUE);



    lioc = qio_channel_socket_new();

    qio_channel_socket_listen_async(

        lioc, listen_addr,

        test_io_channel_complete, &data, NULL);



    g_main_loop_run(data.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!data.err);



    if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) {

        SocketAddress *laddr = qio_channel_socket_get_local_address(

            lioc, &error_abort);



        g_free(connect_addr->u.inet.data->port);

        connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);



        qapi_free_SocketAddress(laddr);

    }



    *src = QIO_CHANNEL(qio_channel_socket_new());



    qio_channel_socket_connect_async(

        QIO_CHANNEL_SOCKET(*src), connect_addr,

        test_io_channel_complete, &data, NULL);



    g_main_loop_run(data.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!data.err);



    qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);

    *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));

    g_assert(*dst);



    qio_channel_set_delay(*src, false);

    test_io_channel_set_socket_bufs(*src, *dst);



    object_unref(OBJECT(lioc));



    g_main_loop_unref(data.loop);

}

static void FUNC_0(SocketAddress *VAR_0,

                                        SocketAddress *VAR_1,

                                        QIOChannel **VAR_2,

                                        QIOChannel **VAR_3)

{

    QIOChannelSocket *lioc;

    struct TestIOChannelData VAR_4;



    VAR_4.loop = g_main_loop_new(g_main_context_default(),

                                TRUE);



    lioc = qio_channel_socket_new();

    qio_channel_socket_listen_async(

        lioc, VAR_0,

        test_io_channel_complete, &VAR_4, NULL);



    g_main_loop_run(VAR_4.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!VAR_4.err);



    if (VAR_0->type == SOCKET_ADDRESS_KIND_INET) {

        SocketAddress *laddr = qio_channel_socket_get_local_address(

            lioc, &error_abort);



        g_free(VAR_1->u.inet.VAR_4->port);

        VAR_1->u.inet.VAR_4->port = g_strdup(laddr->u.inet.VAR_4->port);



        qapi_free_SocketAddress(laddr);

    }



    *VAR_2 = QIO_CHANNEL(qio_channel_socket_new());



    qio_channel_socket_connect_async(

        QIO_CHANNEL_SOCKET(*VAR_2), VAR_1,

        test_io_channel_complete, &VAR_4, NULL);



    g_main_loop_run(VAR_4.loop);

    g_main_context_iteration(g_main_context_default(), FALSE);



    g_assert(!VAR_4.err);



    qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);

    *VAR_3 = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));

    g_assert(*VAR_3);



    qio_channel_set_delay(*VAR_2, false);

    test_io_channel_set_socket_bufs(*VAR_2, *VAR_3);



    object_unref(OBJECT(lioc));



    g_main_loop_unref(VAR_4.loop);

}

static void FUNC_0(SocketAddress *VAR_0,
SocketAddress *VAR_1,
QIOChannel **VAR_2,
QIOChannel **VAR_3)
{ QIOChannelSocket *lioc; struct TestIOChannelData VAR_4; VAR_4.loop = g_main_loop_new(g_main_context_default(),
TRUE); lioc = qio_channel_socket_new(); qio_channel_socket_listen_async(
lioc, VAR_0,
test_io_channel_complete, &VAR_4, NULL); g_main_loop_run(VAR_4.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!VAR_4.err); if (VAR_0->type == SOCKET_ADDRESS_KIND_INET) { SocketAddress *laddr = qio_channel_socket_get_local_address(
lioc, &error_abort); g_free(VAR_1->u.inet.VAR_4->port); VAR_1->u.inet.VAR_4->port = g_strdup(laddr->u.inet.VAR_4->port); qapi_free_SocketAddress(laddr); } *VAR_2 = QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_async(
QIO_CHANNEL_SOCKET(*VAR_2), VAR_1,
test_io_channel_complete, &VAR_4, NULL); g_main_loop_run(VAR_4.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!VAR_4.err); qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); *VAR_3 = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); g_assert(*VAR_3); qio_channel_set_delay(*VAR_2, false); test_io_channel_set_socket_bufs(*VAR_2, *VAR_3); object_unref(OBJECT(lioc)); g_main_loop_unref(VAR_4.loop); }