diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2013-11-30 05:50:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2013-11-30 05:50:55 (GMT) |
commit | 43845ae14d68aa6a945c50993b144d93bc9baa67 (patch) | |
tree | 51afb8a23ed70ec707a102530b29e9fd8dc3a8b2 /src | |
parent | c31111a5f0d79cfc05c84619187f4ed6da22ab69 (diff) | |
download | hdf5-43845ae14d68aa6a945c50993b144d93bc9baa67.zip hdf5-43845ae14d68aa6a945c50993b144d93bc9baa67.tar.gz hdf5-43845ae14d68aa6a945c50993b144d93bc9baa67.tar.bz2 |
[svn-r24475] 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
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 40 | ||||
-rw-r--r-- | src/H5Faccum.c | 4 | ||||
-rw-r--r-- | src/H5Fio.c | 2 | ||||
-rw-r--r-- | src/H5Fpkg.h | 1 | ||||
-rw-r--r-- | src/H5Fprivate.h | 2 | ||||
-rw-r--r-- | src/H5Fquery.c | 2 | ||||
-rw-r--r-- | src/H5Fsuper_cache.c | 2 |
7 files changed, 26 insertions, 27 deletions
@@ -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 */ @@ -1325,7 +1335,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") /* 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 { @@ -1346,25 +1356,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. */ @@ -2123,12 +2126,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 529384b..949ebde 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -431,7 +431,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 */ @@ -731,7 +731,7 @@ HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); } /* end else */ } /* end if */ else { - if((f->intent & H5F_ACC_SWMR_WRITE) > 0) { + if((H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0) { /* Flush if dirty and reset accumulator */ if(H5F_accum_reset(f, dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") diff --git a/src/H5Fio.c b/src/H5Fio.c index 4f15017..28c7c2b 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 828d464..4a1d3e6 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 09dfcec..391f290 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/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 705507d..cc411d5 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -474,7 +474,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) * as the file can appear truncated if only part of it has been * been flushed to disk by the single writer process.) */ - if (!(f->intent & H5F_ACC_SWMR_READ)) { + if (!(H5F_INTENT(f) & H5F_ACC_SWMR_READ)) { if(HADDR_UNDEF == (eof = H5FD_get_eof(lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine file size") |