On Wed, Sep 12, 2012 at 2:35 PM, John Chen <john...@gmail.com> wrote:
> Tim,
>
> If I call the same code with one thread, it works without any problem. so
> I believe it has something to do with how libusb work in multi-threading
> code.
>
> Do you have any sample code how to handle multi-threading for libusb
> asynchronous operations? do I need to anything to protect call to
> libusb_handle_events_timeout_completed ? (can
> libusb_handle_events_timeout_completed
> be call at same time from multiple thread?)
> Did I do anything wrong in the loop? anything I am suppose to do I did not
> do in code?
>
> I pretty much showed you the whole libusb related code here, the only
> thing I did not show is the client, which is very complicated and I am not
> sure how it was related to this libusb problem.
>
> The bottom line is I got a client spawn multiple threads, calling my code,
> one BulkRead, one BulkWrite, in both function, it has the
> same identical loop as following:
> while (!userdata->ExitTransfer)
> {
> //I also added Lock here for the whole block here and
> to serialize the call to
> //libusb_handle_events_timeout_completed, but it still does not work.
> struct timeval tv = { 1, 0 };
> int completed =0;
>
> err = libusb_handle_events_timeout_completed(NULL, &tv,&completed );
> }
>
>
>
>
>
Tim said: "It looks like you are running multiple simultaneous event loops.
Is that correct? You don't need to do that."
Did you address that?
Don't put the libusb_handle_events_timeout_completed where you currently
have it.... Have just one event loop thread. So when your code initializes,
create a thread that does this event handling and move the event handling
out of your code that is doing the submit_transfer.
Dave
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel