Path: utzoo!attcan!uunet!cbmvax!jesup From: jesup@cbmvax.UUCP (Randell Jesup) Newsgroups: comp.sys.amiga.tech Subject: Re: How to close a device, cont Message-ID: <5579@cbmvax.UUCP> Date: 27 Dec 88 21:27:17 GMT References: <587@abo.fi> <588@abo.fi> Reply-To: jesup@cbmvax.UUCP (Randell Jesup) Organization: Commodore Technology, West Chester, PA Lines: 31 In article <588@abo.fi> rosenbergr@abo.fi (Robin Rosenberg) writes: >In article <587@abo.fi>, vinsci@abo.fi (Leonard Norrgard) writes: >> What is the *correct* order to close a device and free buffer memory & >> replyports? Close it, then free things. >When I do CloseDevice. What happens to a (maybe) pending I/O-request. Do >I have to AbortIO(it) or does CloseDevice do that. If I have to abort it, >what happens if the request is not pending anymore ?. I can't find any way >to be sure that a request is not pending. Ok I do CheckIO and find it's >still pending, then I do AbortIO. But if the request is returned between >CheckIO and AbortIO, i will be aborting a nonpending request. Does anyone >know the *CORRECT* way of closing up a device ? Almost correct. You always want to WaitIO(it) after an AbortIO. AbortIO asks for an abort, but the abort may take time to complete, or it maybe too late to abort. The WaitIO() assures that the request has been replied, and it's safe to reuse it. Another note for those using IORequests, that has been discussed here before: DO NOT assume that a signal on the reply port for something that has been SendIO()ed or BeginIO()ed means the message has come back. Use the signal as an instruction to either WaitIO() or CheckIO then WaitIO if it is done. (You can also use CheckIO/GetMsg if you are using no other IORequests on that port, but I recommend against it). Welcome to the wonderful world of IO! :-) -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup