|
From: Stephan M. <ste...@we...> - 2006-11-06 19:10:45
|
I think this bug can be fixed by adding WaitForSingleObject() after _usb_cancel_io()
So, usb_cancel_async() would look like this:
int usb_cancel_async(void *context)
{
...
_usb_cancel_io(c);
WaitForSingleObject(c->ol.hEvent, 0);
return 0;
}
Or, WaitForSingleObject() could be added to _usb_cancel_io() directly:
static int _usb_cancel_io(usb_context_t *context)
{
int ret;
ret = _usb_abort_ep(context->dev, context->req.endpoint.endpoint);
WaitForSingleObject(context->ol.hEvent, 0);
return ret;
}
Please let me know if this helps,
Stephan
> We've seen some problems when stress testing doing plug/unplug. Mysterious memory corruption was occuring and it turned out ot be in the aynchronous context blocks.
>
>
>
> Part of the problem seems to be that the result of the _usb_cancel_io function isn't used, so usb_cancel_async can return apparently successfully before the io has completed. This can result in memory corruption because Windows writes to the overlapped structure even though the Event handle has been closed in usb_free_async.
>
>
>
> I'm not sure what the correct solution is, but it would help if usb_cancel_async returned the error from usb_cancel_io so that we didn't then try and free the transfer, but you'd then have to not call usb_free_async if an error occured (or try it again until it succeeded).
>
>
>
> At the moment we've implemented a horrible solution of adding a delay after the usb_cancel_io before trying to free it. By adding in checking code, we can see that the memory gets altered sometimes even after the call to usb_free_async, and the delay seems to sort it out.
>
>
>
>
> --
> Dan Ellis
> DisplayLink (UK) Limited (Formerly Newnham Research)
>
>
> -----------------------------------------------------------------
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
> -----------------------------------------------------------------
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
|