tdb: reset tdb->fd to -1 in tdb_close()
authorKirill Smelkov <kirr@mns.spb.ru>
Wed, 21 Oct 2009 17:18:56 +0000 (21:18 +0400)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 28 Oct 2009 23:44:33 +0000 (10:14 +1030)
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>
lib/tdb/common/open.c

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