ted@blia.BLI.COM (Ted Marshall) (04/14/88)
In article <282@cullsj.UUCP>, jayz@cullsj.UUCP (Jay Zorzy) writes: > Speaking of stacks, here's a common gotcha to watch out for: If you're > issuing any asynchronous $QIOs (no wait, I/O completion handled by AST > routine), make sure to declare your IOSB variables as static. Otherwise, > once the calling routine returns, the stack is reset; an IOSB on the stack > may now point to never-never land. This can bite you even if you use QIOW, IF you have an condition handler which unwinds the stack. This bit me. In our VMS host code, the QIOW read sits waiting for data to come back from the database server. If the user types ^C, The AST routine signals a condition and the handler unwinds the stack before cancelling the QIO (actually this was with our private exception handler instead of the standard VMS condition handler, but it's the same difference). I fixed that by making the IOSBs static. Of course, be careful about making things static if the routine is recusive! -- Ted Marshall ...!ucbvax!mtxinu!blia!ted <or> mtxinu!blia!ted@Berkeley.EDU Britton Lee, Inc., 14600 Winchester Blvd, Los Gatos, Ca 95030 (408)378-7000 The opinions expressed above are those of the poster and not his employer.
kvc@nrcvax.UUCP (Kevin Carosso) (04/17/88)
In article <4500@blia.BLI.COM> ted@blia.BLI.COM (Ted Marshall) writes: >In article <282@cullsj.UUCP>, jayz@cullsj.UUCP (Jay Zorzy) writes: >> Speaking of stacks, here's a common gotcha to watch out for: If you're >> issuing any asynchronous $QIOs (no wait, I/O completion handled by AST >> routine), make sure to declare your IOSB variables as static. Otherwise, >> once the calling routine returns, the stack is reset; an IOSB on the stack >> may now point to never-never land. > >This can bite you even if you use QIOW, IF you have an condition handler >which unwinds the stack. This bit me. > . . . >Of course, be careful about making things static if the routine is recusive! > One way of handling asynch I/O's fairly cleanly is to create a structure for each I/O you do, consisting of, for example, the buffer for the I/O, the IOSB, and anything else you might want. Before you issue your QIO, allocate your struct and link it into a list. Your listhead should, of course, be static. If you use AST completion on the I/O, you can pass the address of the per-I/O struct as the AST parameter, making your buffer, your IOSB, etc. easily accessible to your completion handler. When you're done with the I/O, you've got a lot of options. You should unlink from the list and then deallocate the struct, put it on a free list for later re-user, or maybe move it to another list to be post-processed. /Kevin Carosso kvc@nrc.com Network Research Co. kvc@ymir.bitnet kvc@nrcvax.uucp