mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
disable refcounting until semantics are decided
This commit is contained in:
parent
13b6603ccb
commit
deeca5fb83
@ -28,7 +28,9 @@ typedef struct NC {
|
||||
char* path;
|
||||
int mode; /* as provided to nc_open/nc_create */
|
||||
int substrate;
|
||||
#ifdef USE_REFCOUNT
|
||||
int refcount; /* To enable multiple name-based opens */
|
||||
#endif
|
||||
} NC;
|
||||
|
||||
/*
|
||||
|
@ -547,6 +547,9 @@ netCDF library.
|
||||
If a the path is a DAP URL, then the open mode is read-only.
|
||||
Setting NC_WRITE will be ignored.
|
||||
|
||||
As of version 4.3.1.2, multiple calls to nc_open with the same
|
||||
path will return the same ncid value.
|
||||
|
||||
\note When opening a netCDF-4 file HDF5 error reporting is turned off,
|
||||
if it is on. This doesn't stop the HDF5 error stack from recording the
|
||||
errors, it simply stops their display to the user through stderr.
|
||||
@ -1034,9 +1037,11 @@ nc_abort(int ncid)
|
||||
int stat = NC_check_id(ncid, &ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
|
||||
#ifdef USE_REFCOUNT
|
||||
/* What to do if refcount > 0? */
|
||||
/* currently, forcibly abort */
|
||||
ncp->refcount = 0;
|
||||
#endif
|
||||
|
||||
stat = ncp->dispatch->abort(ncid);
|
||||
del_from_NCList(ncp);
|
||||
@ -1091,8 +1096,10 @@ nc_close(int ncid)
|
||||
int stat = NC_check_id(ncid, &ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
|
||||
#ifdef USE_REFCOUNT
|
||||
ncp->refcount--;
|
||||
if(ncp->refcount <= 0)
|
||||
#endif
|
||||
{
|
||||
stat = ncp->dispatch->close(ncid);
|
||||
/* Remove from the nc list */
|
||||
@ -1602,6 +1609,11 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
/* Add to list of known open files and define ext_ncid */
|
||||
add_to_NCList(ncp);
|
||||
|
||||
#ifdef USE_REFCOUNT
|
||||
/* bump the refcount */
|
||||
ncp->refcount++;
|
||||
#endif
|
||||
|
||||
/* Assume create will fill in remaining ncp fields */
|
||||
if ((stat = dispatcher->create(path, cmode, initialsz, basepe, chunksizehintp,
|
||||
useparallel, mpi_info, dispatcher, ncp))) {
|
||||
@ -1651,6 +1663,7 @@ NC_open(const char *path, int cmode,
|
||||
nc_initialized = 1;
|
||||
}
|
||||
|
||||
#ifdef USE_REFCOUNT
|
||||
/* If this path is already open, then bump the refcount and return it */
|
||||
ncp = find_in_NCList_by_name(path);
|
||||
if(ncp != NULL) {
|
||||
@ -1658,6 +1671,7 @@ NC_open(const char *path, int cmode,
|
||||
if(ncidp) *ncidp = ncp->ext_ncid;
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
isurl = NC_testurl(path);
|
||||
if(isurl)
|
||||
@ -1749,6 +1763,11 @@ havetable:
|
||||
/* Add to list of known open files */
|
||||
add_to_NCList(ncp);
|
||||
|
||||
#ifdef USE_REFCOUNT
|
||||
/* bump the refcount */
|
||||
ncp->refcount++;
|
||||
#endif
|
||||
|
||||
/* Assume open will fill in remaining ncp fields */
|
||||
stat = dispatcher->open(path, cmode, basepe, chunksizehintp,
|
||||
useparallel, mpi_info, dispatcher, ncp);
|
||||
|
@ -42,9 +42,11 @@ add_to_NCList(NC* ncp)
|
||||
return NC_ENOMEM;
|
||||
numfiles = 0;
|
||||
}
|
||||
#ifdef USE_REFCOUNT
|
||||
/* Check the refcount */
|
||||
if(ncp->refcount > 0)
|
||||
return NC_NOERR;
|
||||
#endif
|
||||
|
||||
new_id = 0; /* id's begin at 1 */
|
||||
for(i=1; i < NCFILELISTLENGTH; i++) {
|
||||
@ -64,9 +66,11 @@ del_from_NCList(NC* ncp)
|
||||
unsigned int ncid = ((unsigned int)ncp->ext_ncid) >> ID_SHIFT;
|
||||
if(numfiles == 0 || ncid == 0 || nc_filelist == NULL) return;
|
||||
if(nc_filelist[ncid] != ncp) return;
|
||||
#ifdef USE_REFCOUNT
|
||||
/* Check the refcount */
|
||||
if(ncp->refcount > 0)
|
||||
return; /* assume caller has decrecmented */
|
||||
#endif
|
||||
|
||||
nc_filelist[ncid] = NULL;
|
||||
numfiles--;
|
||||
|
Loading…
Reference in New Issue
Block a user