Browse Source

Import f5c992bdaeb73ef726ff4728a9922721474cd6f5 from ctdb:

    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>
Rusty Russell 16 years ago
parent
commit
56320b5f5d
1 changed files with 3 additions and 1 deletions
  1. 3 1
      ccan/tdb/open.c

+ 3 - 1
ccan/tdb/open.c

@@ -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 */