[PATCH 3/5] tdb: reset tdb->fd to -1 in tdb_close()

Kirill Smelkov kirr at mns.spb.ru
Wed Oct 21 11:18:56 MDT 2009


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 at mns.spb.ru>
---
 lib/tdb/common/open.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 1ba2e7b..64efafe 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/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 */
-- 
1.6.5.1.63.ga9d7



More information about the samba-technical mailing list