From b4424f8234a78a79fb2d71d46ca208b4f12e0f9e Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Wed, 21 Oct 2009 21:18:56 +0400 Subject: 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 Signed-off-by: Rusty Russell --- lib/tdb/common/open.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index 1ba2e7bd11..64efafeb22 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 */ -- cgit