diff options
Diffstat (limited to 'src/H5Fmount.c')
-rw-r--r-- | src/H5Fmount.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 73a450d..c67f40d 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -78,9 +78,14 @@ H5F_close_mounts(H5F_t *f) /* Unmount all child files */ for (u = 0; u < f->mtab.nmounts; u++) { + /* Detach the child file from the parent file */ f->mtab.child[u].file->mtab.parent = NULL; + + /* Close the internal group maintaining the mount point */ if(H5G_close(f->mtab.child[u].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close child group") + + /* Close the child file */ if(H5F_close(f->mtab.child[u].file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") } /* end if */ @@ -633,13 +638,13 @@ done: static hbool_t H5F_check_mounts_recurse(H5F_t *f) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_check_mounts_recurse) /* Check if this file is closing and if the only objects left open are * the mount points */ - if(f->closing && f->nopen_objs == f->mtab.nmounts) { + if((f->closing || (f->nrefs == 1 && f->mtab.parent)) && f->nopen_objs == f->mtab.nmounts) { unsigned u; /* Iterate over files mounted in this file and check if all can be closed */ @@ -648,9 +653,10 @@ H5F_check_mounts_recurse(H5F_t *f) || !H5F_check_mounts_recurse(f->mtab.child[u].file)) HGOTO_DONE(FALSE) } /* end for */ - } /* end if */ - ret_value = TRUE; + /* Set return value */ + ret_value = TRUE; + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -703,7 +709,8 @@ H5F_check_mounts(H5F_t *f) if(H5F_close_mounts(top) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't unmount child file") - H5I_dec_ref(top->closing); + if(H5I_dec_ref(top->closing) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't decrement file closing ID") } /* end if */ } /* end if */ |