static int vnc_client_io_error(VncState *vs, int ret, int last_errno)

{

    if (ret == 0 || ret == -1) {

        if (ret == -1) {

            switch (last_errno) {

                case EINTR:

                case EAGAIN:

#ifdef _WIN32

                case WSAEWOULDBLOCK:

#endif

                    return 0;

                default:

                    break;

            }

        }



	VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0);

	qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);

	closesocket(vs->csock);

        qemu_del_timer(vs->timer);

        qemu_free_timer(vs->timer);

        if (vs->input.buffer) qemu_free(vs->input.buffer);

        if (vs->output.buffer) qemu_free(vs->output.buffer);

#ifdef CONFIG_VNC_TLS

	if (vs->tls_session) {

	    gnutls_deinit(vs->tls_session);

	    vs->tls_session = NULL;

	}

#endif /* CONFIG_VNC_TLS */

        audio_del(vs);



        VncState *p, *parent = NULL;

        for (p = vs->vd->clients; p != NULL; p = p->next) {

            if (p == vs) {

                if (parent)

                    parent->next = p->next;

                else

                    vs->vd->clients = p->next;

                break;

            }

            parent = p;

        }

        if (!vs->vd->clients)

            dcl->idle = 1;



        qemu_free(vs->old_data);

        qemu_free(vs);

  

	return 0;

    }

    return ret;

}

static int vnc_client_io_error(VncState *vs, int ret, int last_errno)

{

    if (ret == 0 || ret == -1) {

        if (ret == -1) {

            switch (last_errno) {

                case EINTR:

                case EAGAIN:

#ifdef _WIN32

                case WSAEWOULDBLOCK:

#endif

                    return 0;

                default:

                    break;

            }

        }



	VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0);

	qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);

	closesocket(vs->csock);

        qemu_del_timer(vs->timer);

        qemu_free_timer(vs->timer);

        if (vs->input.buffer) qemu_free(vs->input.buffer);

        if (vs->output.buffer) qemu_free(vs->output.buffer);

#ifdef CONFIG_VNC_TLS

	if (vs->tls_session) {

	    gnutls_deinit(vs->tls_session);

	    vs->tls_session = NULL;

	}

#endif 

        audio_del(vs);



        VncState *p, *parent = NULL;

        for (p = vs->vd->clients; p != NULL; p = p->next) {

            if (p == vs) {

                if (parent)

                    parent->next = p->next;

                else

                    vs->vd->clients = p->next;

                break;

            }

            parent = p;

        }

        if (!vs->vd->clients)

            dcl->idle = 1;



        qemu_free(vs->old_data);

        qemu_free(vs);

  

	return 0;

    }

    return ret;

}

static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)

{

    if (VAR_1 == 0 || VAR_1 == -1) {

        if (VAR_1 == -1) {

            switch (VAR_2) {

                case EINTR:

                case EAGAIN:

#ifdef _WIN32

                case WSAEWOULDBLOCK:

#endif

                    return 0;

                default:

                    break;

            }

        }



	VNC_DEBUG("Closing down client sock %d %d\n", VAR_1, VAR_1 < 0 ? VAR_2 : 0);

	qemu_set_fd_handler2(VAR_0->csock, NULL, NULL, NULL, NULL);

	closesocket(VAR_0->csock);

        qemu_del_timer(VAR_0->timer);

        qemu_free_timer(VAR_0->timer);

        if (VAR_0->input.buffer) qemu_free(VAR_0->input.buffer);

        if (VAR_0->output.buffer) qemu_free(VAR_0->output.buffer);

#ifdef CONFIG_VNC_TLS

	if (VAR_0->tls_session) {

	    gnutls_deinit(VAR_0->tls_session);

	    VAR_0->tls_session = NULL;

	}

#endif 

        audio_del(VAR_0);



        VncState *p, *parent = NULL;

        for (p = VAR_0->vd->clients; p != NULL; p = p->next) {

            if (p == VAR_0) {

                if (parent)

                    parent->next = p->next;

                else

                    VAR_0->vd->clients = p->next;

                break;

            }

            parent = p;

        }

        if (!VAR_0->vd->clients)

            dcl->idle = 1;



        qemu_free(VAR_0->old_data);

        qemu_free(VAR_0);

  

	return 0;

    }

    return VAR_1;

}

static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)
{ if (VAR_1 == 0 || VAR_1 == -1) { if (VAR_1 == -1) { switch (VAR_2) { case EINTR:
case EAGAIN:
#ifdef _WIN32
case WSAEWOULDBLOCK:
#endif
return 0; default:
break; } } VNC_DEBUG("Closing down client sock %d %d\n", VAR_1, VAR_1 < 0 ? VAR_2 : 0); qemu_set_fd_handler2(VAR_0->csock, NULL, NULL, NULL, NULL); closesocket(VAR_0->csock); qemu_del_timer(VAR_0->timer); qemu_free_timer(VAR_0->timer); if (VAR_0->input.buffer) qemu_free(VAR_0->input.buffer); if (VAR_0->output.buffer) qemu_free(VAR_0->output.buffer); #ifdef CONFIG_VNC_TLS
if (VAR_0->tls_session) { gnutls_deinit(VAR_0->tls_session); VAR_0->tls_session = NULL; } #endif
audio_del(VAR_0); VncState *p, *parent = NULL; for (p = VAR_0->vd->clients; p != NULL; p = p->next) { if (p == VAR_0) { if (parent)
parent->next = p->next; else
VAR_0->vd->clients = p->next; break; } parent = p; } if (!VAR_0->vd->clients)
dcl->idle = 1; qemu_free(VAR_0->old_data); qemu_free(VAR_0); return 0; } return VAR_1; }