]> git.ozlabs.org Git - ccan/commitdiff
Import f5c992bdaeb73ef726ff4728a9922721474cd6f5 from ctdb:
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 2 Feb 2010 01:34:25 +0000 (12:04 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 2 Feb 2010 01:34:25 +0000 (12:04 +1030)
    tdb: reset tdb->fd to -1 in tdb_close()

    So that erroneous double tdb_close() calls do not try to close() same
    fd again. This is like SAFE_FREE() but for fd.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    (cherry picked from samba commit b4424f8234a78a79fb2d71d46ca208b4f12e0f9e)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
ccan/tdb/open.c

index 8b9776864a6729a5a85bcfe470c73c709db45364..50f60816b77f5dd9ec986e527b812a8c6d116d47 100644 (file)
@@ -403,8 +403,10 @@ int tdb_close(struct tdb_context *tdb)
                        tdb_munmap(tdb);
        }
        SAFE_FREE(tdb->name);
                        tdb_munmap(tdb);
        }
        SAFE_FREE(tdb->name);
-       if (tdb->fd != -1)
+       if (tdb->fd != -1) {
                ret = close(tdb->fd);
                ret = close(tdb->fd);
+               tdb->fd = -1;
+       }
        SAFE_FREE(tdb->lockrecs);
 
        /* Remove from contexts list */
        SAFE_FREE(tdb->lockrecs);
 
        /* Remove from contexts list */