]> git.sur5r.net Git - cc65/commitdiff
close IOCB if open failed -- otherwise is is still marked as "in use"
authorChristian Groessler <chris@groessler.org>
Tue, 9 Jul 2013 21:39:42 +0000 (23:39 +0200)
committerChristian Groessler <chris@groessler.org>
Tue, 9 Jul 2013 21:39:42 +0000 (23:39 +0200)
libsrc/atari/graphics.s
libsrc/atari/open.s
libsrc/atari/posixdirent.s

index cad5412bc3298120fd36fb5f75fc8246231edd3e..ab26ed0da90bb4f36dcbaee73fb6a00fe34e372e 100644 (file)
         .export __graphics
 
         .import findfreeiocb
-        .import __do_oserror,__oserror
+        .import __oserror
         .import fddecusage
         .import clriocb
         .import fdtoiocb
         .import newfd
-       .import scrdev
+        .import scrdev
         .importzp tmp1,tmp2,tmp3
 
         .include        "atari.inc"
@@ -97,7 +97,12 @@ doopen: txa
         stx     __oserror
         rts
 
-cioerr: jsr     fddecusage      ; decrement usage counter of fd as open failed
-        jmp     __do_oserror
+cioerr: sty     tmp3            ; remember error code
+        lda     #CLOSE
+        sta     ICCOM,x
+        jsr     CIOV            ; close IOCB again since open failed
+        jsr     fddecusage      ; and decrement usage counter of fd
+        lda     tmp3            ; put error code into A
+        jmp     __mappederrno
 
 .endproc        ; __graphics
index 8aeff9ed4d24ba4fabe3def1ddc9d151c9686225..306cf52c21feb66adf18f7a2b7bbba0f641305a0 100644 (file)
@@ -140,8 +140,12 @@ finish: php
         plp
 
         bpl     ok
-        jsr     fddecusage      ; decrement usage counter of fd as open failed
-        tya                     ; put error code into A
+        sty     tmp3            ; remember error code
+        lda     #CLOSE
+        sta     ICCOM,x
+        jsr     CIOV            ; close IOCB again since open failed
+        jsr     fddecusage      ; and decrement usage counter of fd
+        lda     tmp3            ; put error code into A
         jmp     __mappederrno
 
 ok:     lda     tmp2            ; get fd
index 3417e4bfc8229f3cba4f5ef8a984c7f6f85d1ad6..a722b3b06f74a58bdd3732cc5cca714c1d7d64ba 100644 (file)
@@ -63,6 +63,9 @@
 .endproc
 
 cioerr:         sty     __oserror
+                lda     #CLOSE
+                sta     ICCOM,x
+                jsr     CIOV            ; close IOCB again since open failed
                 jmp     return0
 
 .proc   _readdir