AristoChen / usb-proxy

A USB proxy based on raw-gadget and libusb
Apache License 2.0
152 stars 29 forks source link

why event.inner.length == 4294967295 ep0_loop return #5

Open imatespl opened 1 year ago

imatespl commented 1 year ago

I run usb-proxy in banana pi m2 plus, when i disconnect usb device from broad then raw_gadget return 4294967295, this number ep0_loop break, so usb_proxy main thread Segmentation fault ./usb-proxy --device=musb-hdrc.4.auto --driver=musb-hdrc Device is: musb-hdrc.4.auto Driver is: musb-hdrc vendor_id is: -1 product_id is: -1 Device opened successfully Setup USB config successfully Start hotplug_monitor thread, thread id(10504) Start for EP0, thread id(10487) event: connect, length: 0 Hotplug event Received SIGINT, stopping... event: unknown, length: 4294967295 End for EP0, thread id(10487) Segmentation fault

i want to known why event.inner.length == 4294967295 ep0_loop return,thanks

AristoChen commented 1 year ago

Hi @imatespl ,

Thank you for being interesting in this project, and sorry for the late reply.

There is a hotplug detecting mechanism for USB device, once the USB device hotplug event is detected, it will send a SIGINT signal, and which will cause usb_raw_event_fetch recived a EINTR, inorder to identify whether the EINTR is caused by hotplug or real EINTR, so I set the length to UINT_MAX(which is 4294967295) to identify that it is highly possible that EINTR is caused by USB device hotplug

imatespl commented 1 year ago

Thank you very very much,this make process Segmentation fault,when remove usb device from host

        if (event.inner.length == 4294967295) {
            printf("End for EP0, thread id(%d)\n", gettid());
            return;
        }