From 4df5dc8c5387707fa0cd628907d68026f0251fb9 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Wed, 21 Oct 2009 21:18:56 +0400 Subject: [PATCH] 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 (cherry picked from commit b4424f8234a78a79fb2d71d46ca208b4f12e0f9e) Signed-off-by: Stefan Metzmacher --- lib/tdb/common/open.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index 1ba2e7bd11a..64efafeb226 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 */ -- 2.34.1