summaryrefslogtreecommitdiff
path: root/mapfile.c
diff options
context:
space:
mode:
authorLukasz Dorau <lukasz.dorau@intel.com>2011-10-03 08:55:02 +1100
committerNeilBrown <neilb@suse.de>2011-10-03 08:55:02 +1100
commitcc700db34f6fb565b37f4edf7fe7fe40a5f2745b (patch)
treee66823392910fe75f39af2fcb624ae10d68fced0 /mapfile.c
parente3da7890555d8cfe17fd9ee4f5f04ab64f855919 (diff)
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 <lukasz.dorau@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mapfile.c')
-rw-r--r--mapfile.c12
1 files changed, 12 insertions, 0 deletions
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)
{