summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-07-11 18:50:36 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-07-11 18:50:36 (GMT)
commit737f86822de263712164746025f48ca2fca410db (patch)
treec719b8d87df4df9835cdfd37cdb898462e1ecfd1
parent650ca6a21849a31b29ae0e4644edb934b5cb3783 (diff)
downloadhdf5-737f86822de263712164746025f48ca2fca410db.zip
hdf5-737f86822de263712164746025f48ca2fca410db.tar.gz
hdf5-737f86822de263712164746025f48ca2fca410db.tar.bz2
[svn-r22554] remove the file_id from the H5F_t struct and add an id_exists instead
-rw-r--r--src/H5F.c30
-rw-r--r--src/H5Fint.c15
-rw-r--r--src/H5Fmount.c2
-rw-r--r--src/H5Fpkg.h2
-rw-r--r--src/H5Fprivate.h6
-rw-r--r--src/H5Fquery.c6
-rw-r--r--src/H5I.c6
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Ocopy.c2
-rw-r--r--src/H5VLnative.c52
10 files changed, 22 insertions, 101 deletions
diff --git a/src/H5F.c b/src/H5F.c
index cf38bc2..d5e15be 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -508,10 +508,6 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if((ret_value = H5I_register2(H5I_FILE, file, vol_plugin, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
- /* MSC (need to change) -
- * If this was done through the native plugin, store the ID created in the H5F_t struct */
- if((HDstrcmp(vol_plugin->cls->name, "native") == 0))
- ((H5F_t *)file)->file_id = ret_value;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fcreate() */
@@ -588,10 +584,6 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
if((ret_value = H5I_register2(H5I_FILE, file, vol_plugin, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
- /* MSC (need to change) -
- * If this was done through the native plugin, store the ID created in the H5F_t struct */
- if((HDstrcmp(vol_plugin->cls->name, "native") == 0))
- ((H5F_t *)file)->file_id = ret_value;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fopen() */
@@ -789,11 +781,6 @@ H5Freopen(hid_t file_id)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
vol_plugin->nrefs ++;
- /* MSC (need to change) -
- * If this was done through the native plugin, store the ID created in the H5F_t struct */
- if((HDstrcmp(vol_plugin->cls->name, "native") == 0))
- ((H5F_t *)file)->file_id = ret_value;
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Freopen() */
@@ -1444,32 +1431,17 @@ H5F_get_id(H5F_t *file, hbool_t app_ref)
HDassert(file);
- /* MSC - Will need to switch to that later */
-#if 1
if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) {
/* resurrect the ID - Register an ID with the native plugin */
if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ file->id_exists = TRUE;
}
else {
/* Increment ref count on existing ID */
if(H5I_inc_ref(ret_value, app_ref) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
}
- file->file_id = ret_value;
-#endif
-#if 0
- if(file->file_id == -1) {
- /* resurrect the ID */
- if((file->file_id = H5VL_native_register(H5I_FILE, file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
- } else {
- /* Increment reference count on atom. */
- if(H5I_inc_ref(file->file_id, app_ref) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
- } /* end else */
- ret_value = file->file_id;
-#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 4ecefe8..e0ce36b 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -645,7 +645,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(NULL == (f = H5FL_CALLOC(H5F_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
- f->file_id = -1;
+ f->id_exists = FALSE;
if(shared) {
HDassert(lf == NULL);
@@ -1270,7 +1270,7 @@ H5F_close(H5F_t *f)
/* Sanity check */
HDassert(f);
- HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */
+ HDassert(f->id_exists); /* This routine should only be called when a file ID's ref count drops to zero */
/* Perform checks for "semi" file close degree here, since closing the
* file is not allowed if there are objects still open */
@@ -1291,7 +1291,7 @@ H5F_close(H5F_t *f)
} /* end if */
/* Reset the file ID for this file */
- f->file_id = -1;
+ f->id_exists = FALSE;
/* Attempt to close the file/mount hierarchy */
if(H5F_try_close(f) < 0)
@@ -1504,15 +1504,6 @@ H5F_reopen(H5F_t *f)
ret_value->open_name = H5MM_xstrdup(f->open_name);
ret_value->actual_name = H5MM_xstrdup(f->actual_name);
- /*
- if((ret_value->file_id = H5I_register(H5I_FILE_PRIVATE, ret_value, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
-
-done:
- if(ret_value->file_id < 0 && ret_value)
- if(H5F_dest(ret_value, H5AC_dxpl_id, FALSE) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close file")
- */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_reopen() */
diff --git a/src/H5Fmount.c b/src/H5Fmount.c
index 6a08921..55f364c 100644
--- a/src/H5Fmount.c
+++ b/src/H5Fmount.c
@@ -599,7 +599,7 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj
HDassert(nopen_objs);
/* If this file is still open, increment number of file IDs open */
- if(f->file_id > 0)
+ if(f->id_exists)
*nopen_files += 1;
/* Increment number of open objects in file
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index a3c7854..669e0d3 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -271,7 +271,7 @@ struct H5F_t {
H5F_file_t *shared; /* The shared file info */
unsigned nopen_objs; /* Number of open object headers*/
H5FO_t *obj_count; /* # of time each object is opened through top file structure */
- hid_t file_id; /* ID of this file */
+ hbool_t id_exists; /* Whether an ID for this struct exists */
hbool_t closing; /* File is in the process of being closed */
struct H5F_t *parent; /* Parent file that this file is mounted to */
unsigned nmounts; /* Number of children mounted to this file */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index e196bd2..b271476 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -257,7 +257,7 @@ typedef struct {
#define H5F_NOPEN_OBJS(F) ((F)->nopen_objs)
#define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++)
#define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--)
-#define H5F_FILE_ID(F) ((F)->file_id)
+#define H5F_FILE_ID(F) ((F)->id_exists)//file_id)
#define H5F_PARENT(F) ((F)->parent)
#define H5F_NMOUNTS(F) ((F)->nmounts)
#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id)
@@ -299,7 +299,7 @@ typedef struct {
#define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F))
#define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F))
#define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F))
-#define H5F_FILE_ID(F) (H5F_get_file_id(F))
+#define H5F_FILE_ID(F) (H5F_file_id_exists(F))
#define H5F_PARENT(F) (H5F_get_parent(F))
#define H5F_NMOUNTS(F) (H5F_get_nmounts(F))
#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F))
@@ -546,7 +546,7 @@ H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2);
H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f);
H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f);
H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f);
-H5_DLL hid_t H5F_get_file_id(const H5F_t *f);
+H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f);
H5_DLL ssize_t H5F_get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len);
H5_DLL H5F_t *H5F_get_parent(const H5F_t *f);
H5_DLL unsigned H5F_get_nmounts(const H5F_t *f);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index c9b21ea..e7dd48b 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -263,15 +263,15 @@ H5F_get_nopen_objs(const H5F_t *f)
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5F_get_file_id(const H5F_t *f)
+hbool_t
+H5F_file_id_exists(const H5F_t *f)
{
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(f);
- FUNC_LEAVE_NOAPI(f->file_id)
+ FUNC_LEAVE_NOAPI(f->id_exists)
} /* end H5F_get_file_id() */
diff --git a/src/H5I.c b/src/H5I.c
index aee6d92..f8150d1 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -2375,12 +2375,8 @@ H5Iget_file_id(hid_t obj_id)
if(H5I_inc_ref(ret_value, TRUE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
}
- /* incrememnt the ref count on the VOL plugin for the new ID */
+ /* increment the ref count on the VOL plugin for the new ID */
vol_plugin->nrefs ++;
- /* MSC (need to change) -
- * If this was done through the native plugin, store the ID created in the H5F_t struct */
- if((HDstrcmp(vol_plugin->cls->name, "native") == 0))
- ((H5F_t *)file)->file_id = ret_value;
}
else
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")
diff --git a/src/H5O.c b/src/H5O.c
index e9df5e6..2926c97 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1642,7 +1642,7 @@ H5O_close(H5O_loc_t *loc)
#ifdef H5O_DEBUG
if(H5DEBUG(O)) {
- if(/*H5F_FILE_ID(loc->file)< 0 &&*/ 1 == H5F_NREFS(loc->file))
+ if(H5F_FILE_ID(loc->file) && 1 == H5F_NREFS(loc->file))
HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n",
loc->addr,
(unsigned long)H5F_NOPEN_OBJS(loc->file));
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index e805cc2..aeaad1a 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -1802,7 +1802,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src,
HDassert(oh_src);
HDassert(oloc_dst);
HDassert(oloc_dst->file);
- HDassert(H5F_FILE_ID(oloc_dst->file) >= 0);
+ HDassert(H5F_FILE_ID(oloc_dst->file));
HDassert(cpy_info);
/* Allocate key */
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index fb5ce4a..2716a13 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -1597,16 +1597,8 @@ H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t f
/* Create the file */
if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id, H5AC_dxpl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file")
-#if 0
- /* Get an atom for the file */
- if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
- /* store a pointer to the VOL class in the file structure */
- new_file->vol_cls = &H5VL_native_g;
- new_file->file_id = file_id;
- if(file_id < 0 && new_file && H5F_try_close(new_file) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
-#endif
+
+ new_file->id_exists = TRUE;
ret_value = (void *)new_file;
done:
@@ -1641,16 +1633,8 @@ H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t UNU
/* Open the file */
if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
-#if 0
- /* Get an atom for the file */
- if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
- /* store a pointer to the VOL class in the file structure */
- new_file->vol_cls = &H5VL_native_g;
- new_file->file_id = file_id;
- if(file_id < 0 && new_file && H5F_try_close(new_file) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
-#endif
+
+ new_file->id_exists = TRUE;
ret_value = (void *)new_file;
done:
@@ -1845,23 +1829,7 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED req, va_l
if(NULL == (f = H5VL_native_get_file(obj, type))) {
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
}
-#if 0
- hbool_t app_ref = va_arg (arguments, hbool_t);
- H5F_t *file = NULL;
- hid_t file_id;
- H5G_loc_t loc; /* Location of object */
-
- if(H5G_loc_real(obj, type, &loc) < 0) {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- }
- /* Get the file ID for the object */
- if((file_id = H5F_get_id(loc.oloc->file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID")
-
- /* return the file object */
- if(NULL == (file = (H5F_t *)H5I_object(file_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
-#endif
+ f->id_exists = TRUE;
*ret = (void*)f;
break;
}
@@ -2137,6 +2105,8 @@ H5VL_native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t U
if(NULL == (new_file = H5F_reopen(f)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
new_file->vol_cls = &H5VL_native_g;
+ new_file->id_exists = TRUE;
+
*ret = (void *)new_file;
break;
}
@@ -2209,14 +2179,6 @@ H5VL_native_file_close(void *file, hid_t UNUSED req)
/* close the file */
if(H5F_close(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file")
-#if 0
- /*
- * Decrement reference count on atom. When it reaches zero the file will
- * be closed.
- */
- if(H5I_dec_app_ref(f->file_id) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
-#endif
done:
FUNC_LEAVE_NOAPI(ret_value)