Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Closing an IOUSBInterface with outstanding I/O



On 10/6/03 9:07 AM, "Jessica Davies" <email@hidden> wrote:

> I was wondering what happens if you issue a Read on an interrupt IOUSBPipe,
> which returns kIOReturnSuccess, then call Abort on the pipe and Close on the
> IOUSBInterface before the callback for the Read has been called?  I seem to
> get a kernel panic when this happens.  Does this count as outstanding I/O
> and therefore you shouldn't call Close on the interface?  This sequence of
> events occurs if I unplug my device without generating any input with it, so
> the callback never gets called.

Your original Read returns kIOReturnSuccess -- meaning that there was no
immediate error trying to queue the read.  The controller will start issuing
the read at the polling rate specified by the endpoint.

When the device is unplugged, you are correct that you need to stop all
pending I/O, usually from your willTerminate() method.  You should NOT call
close() on the provider until all your pending I/O has completed.  The
original read does count as pending I/O until you receive a completion on
the interrupt and you do NOT re-queue the read.  So, in your willTerminate()
you Abort() all your pipes.  Your read interrupt handler will get an error,
either an kIOReturnAborted or a kIOReturnNotResponding.  You should check
whether you are inactive (isInactive() ) before queuing up another read.

You are panic'ing most probably because you closed your provider, which
caused your driver to be released and then the controller attempted to call
your interrupt read handler and that code had been released.  Your driver
will not be unloaded if you don't close() your provider, that's why you
should only do it when all pending I/O has completed.

Do look at the IOUSBHIDDriver for the use of
IncrementOutstandingIO()/DecrementOutstandingIO() and how they use some
fields to indicate whether the provider should be closed in the future, and
stuff like that.


-- 
Fernando Urbina                            mailto:email@hidden
USB Technology Team                           work: 719.534.9387
Apple Computer, Inc.                           fax: 719.532.0981
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.