From cc700db34f6fb565b37f4edf7fe7fe40a5f2745b Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Mon, 3 Oct 2011 08:55:02 +1100 Subject: fix: correct unlocking of map file 1. Three missing map_unlock() calls were added. 2. Map file must be unlocked on fork, else child will hold lock. Signed-off-by: Lukasz Dorau Signed-off-by: NeilBrown --- mapfile.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mapfile.c') diff --git a/mapfile.c b/mapfile.c index ff1e9736..997f0954 100644 --- a/mapfile.c +++ b/mapfile.c @@ -159,6 +159,18 @@ void map_unlock(struct map_ent **melp) lf = NULL; } +void map_fork(void) +{ + /* We are forking, so must close the lock file. + * Don't risk flushing anything though. + */ + if (lf) { + close(fileno(lf)); + fclose(lf); + lf = NULL; + } +} + void map_add(struct map_ent **melp, int devnum, char *metadata, int uuid[4], char *path) { -- cgit v1.2.3