tacme: report close failure in Put, this time for sure - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 93e2e820a5551ba3d0a1e0f0fbd4c5eb65e18ce6
 (DIR) parent f6c9f7b14c9dce53fff6020200b28c4e25621e87
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Fri, 24 Jan 2020 13:08:36 -0500
       
       acme: report close failure in Put, this time for sure
       
       Missed in 0b349f6f that Bterm is not closing fd.
       
       Diffstat:
         M src/cmd/acme/exec.c                 |      10 +++++-----
       
       1 file changed, 5 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
       t@@ -699,7 +699,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
                Rune *r;
                Biobuf *b;
                char *s, *name;
       -        int i, fd, q, ret;
       +        int i, fd, q, ret, retc;
                Dir *d, *d1;
                Window *w;
                int isapp;
       t@@ -763,9 +763,10 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
                        goto Rescue2;
                }
                ret = Bterm(b);
       +        retc = close(fd);
                free(b);
                b = nil;
       -        if(ret < 0) {
       +        if(ret < 0 || retc < 0) {
                        warning(nil, "can't write file %s: %r\n", name);
                        goto Rescue2; // flush or close failed
                }
       t@@ -785,10 +786,9 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
                                // in case we don't have read permission.
                                // (The create above worked, so we probably
                                // still have write permission.)
       -                        close(fd);
                                fd = open(name, OWRITE);
       -
                                d1 = dirfstat(fd);
       +                        close(fd);
                                if(d1 != nil){
                                        free(d);
                                        d = d1;
       t@@ -821,11 +821,11 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
                if(b != nil) {
                        Bterm(b);
                        free(b);
       +                close(fd);
                }
                free(h);
                fbuffree(s);
                fbuffree(r);
       -        close(fd);
                /* fall through */
        
            Rescue1: