/* So we use a bh handler to take care of close events.  */
static void usbredir_chardev_close_bh(void *opaque)
/* So we use a bh handler to take care of close events.  */
static void usbredir_chardev_close_bh(void *opaque)
{
    USBRedirDevice *dev = opaque;
    usbredir_device_disconnect(dev);
    if (dev->parser) {
        DPRINTF("destroying usbredirparser\n");
        usbredirparser_destroy(dev->parser);
        dev->parser = NULL;
    }
    if (dev->watch) {
        g_source_remove(dev->watch);
        dev->watch = 0;
    }
}