Revision 99f08100 usb-redir.c

b/usb-redir.c
881 881
{
882 882
    USBRedirDevice *dev = priv;
883 883

  
884
    if (qemu_timer_pending(dev->attach_timer) || dev->dev.attached) {
885
        ERROR("Received device connect while already connected\n");
886
        return;
887
    }
888

  
884 889
    switch (device_connect->speed) {
885 890
    case usb_redir_speed_low:
886 891
        DPRINTF("attaching low speed device\n");
......
909 914
static void usbredir_device_disconnect(void *priv)
910 915
{
911 916
    USBRedirDevice *dev = priv;
917
    int i;
912 918

  
913 919
    /* Stop any pending attaches */
914 920
    qemu_del_timer(dev->attach_timer);
915 921

  
916 922
    if (dev->dev.attached) {
917 923
        usb_device_detach(&dev->dev);
918
        usbredir_cleanup_device_queues(dev);
919 924
        /*
920 925
         * Delay next usb device attach to give the guest a chance to see
921 926
         * see the detach / attach in case of quick close / open succession
922 927
         */
923 928
        dev->next_attach_time = qemu_get_clock_ms(vm_clock) + 200;
924 929
    }
930

  
931
    /* Reset state so that the next dev connected starts with a clean slate */
932
    usbredir_cleanup_device_queues(dev);
933
    memset(dev->endpoint, 0, sizeof(dev->endpoint));
934
    for (i = 0; i < MAX_ENDPOINTS; i++) {
935
        QTAILQ_INIT(&dev->endpoint[i].bufpq);
936
    }
925 937
}
926 938

  
927 939
static void usbredir_interface_info(void *priv,
......
1013 1025
    DPRINTF("iso status %d ep %02X id %u\n", iso_stream_status->status,
1014 1026
            ep, id);
1015 1027

  
1028
    if (!dev->dev.attached) {
1029
        return;
1030
    }
1031

  
1016 1032
    dev->endpoint[EP2I(ep)].iso_error = iso_stream_status->status;
1017 1033
    if (iso_stream_status->status == usb_redir_stall) {
1018 1034
        DPRINTF("iso stream stopped by peer ep %02X\n", ep);
......
1030 1046
    DPRINTF("interrupt recv status %d ep %02X id %u\n",
1031 1047
            interrupt_receiving_status->status, ep, id);
1032 1048

  
1049
    if (!dev->dev.attached) {
1050
        return;
1051
    }
1052

  
1033 1053
    dev->endpoint[EP2I(ep)].interrupt_error =
1034 1054
        interrupt_receiving_status->status;
1035 1055
    if (interrupt_receiving_status->status == usb_redir_stall) {

Also available in: Unified diff