void aio_set_fd_handler(AioContext *ctx,

                        int fd,

                        IOHandler *io_read,

                        IOHandler *io_write,

                        AioFlushHandler *io_flush,

                        void *opaque)

{

    AioHandler *node;



    node = find_aio_handler(ctx, fd);



    /* Are we deleting the fd handler? */

    if (!io_read && !io_write) {

        if (node) {

            /* If the lock is held, just mark the node as deleted */

            if (ctx->walking_handlers)

                node->deleted = 1;

            else {

                /* Otherwise, delete it for real.  We can't just mark it as

                 * deleted because deleted nodes are only cleaned up after

                 * releasing the walking_handlers lock.

                 */

                QLIST_REMOVE(node, node);

                g_free(node);

            }

        }

    } else {

        if (node == NULL) {

            /* Alloc and insert if it's not already there */

            node = g_malloc0(sizeof(AioHandler));

            node->fd = fd;

            QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);

        }

        /* Update handler with latest information */

        node->io_read = io_read;

        node->io_write = io_write;

        node->io_flush = io_flush;

        node->opaque = opaque;

    }

}

void aio_set_fd_handler(AioContext *ctx,

                        int fd,

                        IOHandler *io_read,

                        IOHandler *io_write,

                        AioFlushHandler *io_flush,

                        void *opaque)

{

    AioHandler *node;



    node = find_aio_handler(ctx, fd);



    

    if (!io_read && !io_write) {

        if (node) {

            

            if (ctx->walking_handlers)

                node->deleted = 1;

            else {

                







                QLIST_REMOVE(node, node);

                g_free(node);

            }

        }

    } else {

        if (node == NULL) {

            

            node = g_malloc0(sizeof(AioHandler));

            node->fd = fd;

            QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);

        }

        

        node->io_read = io_read;

        node->io_write = io_write;

        node->io_flush = io_flush;

        node->opaque = opaque;

    }

}

void FUNC_0(AioContext *VAR_0,

                        int VAR_1,

                        IOHandler *VAR_2,

                        IOHandler *VAR_3,

                        AioFlushHandler *VAR_4,

                        void *VAR_5)

{

    AioHandler *node;



    node = find_aio_handler(VAR_0, VAR_1);



    

    if (!VAR_2 && !VAR_3) {

        if (node) {

            

            if (VAR_0->walking_handlers)

                node->deleted = 1;

            else {

                







                QLIST_REMOVE(node, node);

                g_free(node);

            }

        }

    } else {

        if (node == NULL) {

            

            node = g_malloc0(sizeof(AioHandler));

            node->VAR_1 = VAR_1;

            QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node);

        }

        

        node->VAR_2 = VAR_2;

        node->VAR_3 = VAR_3;

        node->VAR_4 = VAR_4;

        node->VAR_5 = VAR_5;

    }

}

void FUNC_0(AioContext *VAR_0,
int VAR_1,
IOHandler *VAR_2,
IOHandler *VAR_3,
AioFlushHandler *VAR_4,
void *VAR_5)
{ AioHandler *node; node = find_aio_handler(VAR_0, VAR_1); if (!VAR_2 && !VAR_3) { if (node) { if (VAR_0->walking_handlers)
node->deleted = 1; else { QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { node = g_malloc0(sizeof(AioHandler)); node->VAR_1 = VAR_1; QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node); } node->VAR_2 = VAR_2; node->VAR_3 = VAR_3; node->VAR_4 = VAR_4; node->VAR_5 = VAR_5; } }