From 0a506a625b6ce09bf8b87944384e3617f8df5fa7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 30 Nov 2013 00:51:42 -0500 Subject: [svn-r24476] Description: Remove duplicate "intent" flags from top & shared file structures, leaving them only in the shared file structure. Tested on: Mac OSX/64 10.9.0 (amazon) w/gcc 4.8, both parallel & serial (too minor to require h5committest) --- src/H5F.c | 40 ++++++++++++++++++++-------------------- src/H5Faccum.c | 2 +- src/H5Fio.c | 2 +- src/H5Fpkg.h | 1 - src/H5Fprivate.h | 2 +- src/H5Fquery.c | 2 +- src/H5Osdspace.c | 2 +- test/links.c | 6 ++++-- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index b22cdd6..5a06a4d 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -77,8 +77,8 @@ typedef struct H5F_olist_t { /********************/ static herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, - H5FD_t *lf); +static H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, H5FD_t *lf); static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); @@ -884,7 +884,7 @@ done: *------------------------------------------------------------------------- */ static H5F_t * -H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { H5F_t *f = NULL, *ret_value; @@ -907,6 +907,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") + f->shared->flags = flags; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; for(u = 0; u < NELMTS(f->shared->fs_addr); u++) @@ -1019,8 +1020,17 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) done: if(!ret_value && f) { - if(!shared) + if(!shared) { + /* Attempt to clean up some of the shared file structures */ + if(f->shared->efc) + if(H5F_efc_destroy(f->shared->efc) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache") + if(f->shared->fcpl_id > 0) + if(H5I_dec_ref(f->shared->fcpl_id) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") + f->shared = H5FL_FREE(H5F_file_t, f->shared); + } /* end if */ f = H5FL_FREE(H5F_t, f); } /* end if */ @@ -1318,7 +1328,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1339,25 +1349,18 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, } /* end if */ } /* end if */ - if(NULL == (file = H5F_new(NULL, fcpl_id, fapl_id, lf))) + if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") - file->shared->flags = flags; } /* end else */ + /* Retain the name the file was opened with */ + file->open_name = H5MM_xstrdup(name); + /* Short cuts */ shared = file->shared; lf = shared->lf; /* - * The intent at the top level file struct are not necessarily the same as - * the flags at the bottom. The top level describes how the file can be - * accessed through the HDF5 library. The bottom level describes how the - * file can be accessed through the C library. - */ - file->intent = flags; - file->open_name = H5MM_xstrdup(name); - - /* * Read or write the file superblock, depending on whether the file is * empty or not. */ @@ -2110,12 +2113,9 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F_new(old_file->shared, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - /* Keep old file's read/write intent in new file */ - new_file->intent = old_file->intent; - /* Duplicate old file's names */ new_file->open_name = H5MM_xstrdup(old_file->open_name); new_file->actual_name = H5MM_xstrdup(old_file->actual_name); diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 0e549fa..e0ce292 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -426,7 +426,7 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, HDassert(f); HDassert(f->shared); - HDassert(f->intent & H5F_ACC_RDWR); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); HDassert(buf); /* Treat global heap as raw data */ diff --git a/src/H5Fio.c b/src/H5Fio.c index 83c86ea..d494488 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -145,7 +145,7 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size); HDassert(f); HDassert(f->shared); - HDassert(f->intent & H5F_ACC_RDWR); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); HDassert(buf); HDassert(H5F_addr_defined(addr)); diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 5d4ca2f..11d2cd4 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -263,7 +263,6 @@ struct H5F_file_t { * to shared H5F_file_t structs. */ struct H5F_t { - unsigned intent; /* The flags passed to H5F_open()*/ char *open_name; /* Name used to open file */ char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */ char *extpath; /* Path for searching target external link file */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 572df76..3565696 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -280,7 +280,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_PACKAGE -#define H5F_INTENT(F) ((F)->intent) +#define H5F_INTENT(F) ((F)->shared->flags) #define H5F_OPEN_NAME(F) ((F)->open_name) #define H5F_ACTUAL_NAME(F) ((F)->actual_name) #define H5F_EXTPATH(F) ((F)->extpath) diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 6c3ca12..6290614 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -98,7 +98,7 @@ H5F_get_intent(const H5F_t *f) HDassert(f); - FUNC_LEAVE_NOAPI(f->intent) + FUNC_LEAVE_NOAPI(f->shared->flags) } /* end H5F_get_intent() */ diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 905c4e9..9ca8436 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -526,7 +526,7 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, HDfprintf (stream, "{"); for(u = 0; u < sdim->rank; u++) { if(H5S_UNLIMITED==sdim->max[u]) - HDfprintf (stream, "%sINF", u?", ":""); + HDfprintf (stream, "%sUNLIM", u?", ":""); else HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); } /* end for */ diff --git a/test/links.c b/test/links.c index bcffb3e..0f5e2dc 100644 --- a/test/links.c +++ b/test/links.c @@ -4001,6 +4001,9 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) /* Create a group through the external link using gapl (should succeed) */ if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR + /* Close group */ + if(H5Gclose(group) < 0) TEST_ERROR + /* Unset elink access flags on gapl */ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR @@ -4028,8 +4031,7 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) } H5E_END_TRY; if(ret != FAIL) TEST_ERROR - /* Close file1 and group */ - if(H5Gclose(group) < 0) TEST_ERROR + /* Close file1 */ if(H5Fclose(file1) < 0) TEST_ERROR /* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */ -- cgit v0.12