I found the root cause of this problem.

I statically linked libusb-1.0 to my main program.
And I also statically linked libusb-1.0 into a DLL library.

In my main program, I opened a device and in the DLL library, I used 
libusb_control_transfer to work on the device.

Because of static link, there are some static variables in windows_usb.c has 
different copies in both main program and DLL library.

In main program I called libusb_init, this call only initialize the 
libusb_context structure in main program, but in the DLL library, libusb_init 
is not called, therefore, the FD inside the libusb_context of the DLL library 
remains un-initialized.

Solution: dynamically link the program, everything is fixed.
Second solution: windows_usb.c should put the static global variable into 
libusb_context, in this case, only one libusb_context instance will be used 
between different library.

---
Reply to this email directly or view it on GitHub:
https://github.com/libusbx/libusbx/issues/165#issuecomment-30866375
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to