This commit is contained in:
Russ Rew 2014-03-07 13:30:49 -07:00
commit 1da02adcfa
11 changed files with 482 additions and 393 deletions

File diff suppressed because it is too large Load Diff

5
cf
View File

@ -16,6 +16,8 @@ DAP=1
#M32=1
#M64=1
FORCE="-i"
#INSTALL=1
PREFIX=/usr/local
@ -153,6 +155,7 @@ FLAGS="$FLAGS --disable-examples"
#FLAGS="$FLAGS --enable-large-file-tests"
#FLAGS="$FLAGS --disable-testsets"
#FLAGS="$FLAGS --disable-dap-remote-tests"
#FLAGS="$FLAGS --enable-dap-auth-tests"
#FLAGS="$FLAGS --enable-doxygen"
#FLAGS="$FLAGS --enable-logging"
#FLAGS="$FLAGS --disable-diskless"
@ -215,6 +218,6 @@ export DISTCHECK_CONFIGURE_FLAGS
if test -f Makefile ; then ${MAKE} distclean >/dev/null 2>&1 ; fi
sh $X ./configure ${FLAGS}
for c in $cmds; do
${MAKE} $c
${MAKE} ${FORCE} $c
done
exit 0

View File

@ -304,6 +304,22 @@ if test "x$enable_dap" = "xno" ; then
fi
AC_MSG_RESULT($enable_dap_remote_tests)
# Default is now to do the remote authorization tests
AC_MSG_CHECKING([whether dap remote authorization testing should be enabled (default off)])
AC_ARG_ENABLE([dap-auth-test],
[AS_HELP_STRING([--enable-dap-auth-tests],
[enable dap remote authorization tests])])
test "x$enable_dap_auth_tests" = xyes || enable_dap_auth_tests=no
# dap must be enabled
if test "x$enable_dap" = "xno" ; then
enable_dap_auth_tests=no
fi
# if remote tests are disabled, then so is this
if test "x$enable_dap_remote_tests" = "xno" ; then
enable_dap_remote_tests=no
fi
AC_MSG_RESULT($enable_dap_auth_tests)
# Control if groups are supported in [netcdf4]dap2 code
AC_MSG_CHECKING([whether [netcdf4] group names should be enabled (default on)])
AC_ARG_ENABLE([dap-groups],
@ -811,6 +827,7 @@ AM_CONDITIONAL(TEST_PARALLEL, [test "x$enable_parallel" = xyes -a "x$enable_para
AM_CONDITIONAL(BUILD_DAP, [test "x$enable_dap" = xyes])
AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
AM_CONDITIONAL(ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_AUTH_TESTS, [test "x$enable_dap_auth_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_LONG_TESTS, [test "x$enable_dap_long_tests" = xyes])
AM_CONDITIONAL(EXTRA_EXAMPLE_TESTS, [test "x$enable_extra_example_tests" = xyes])
AM_CONDITIONAL(USE_SZIP, [test "x$ac_cv_func_H5Z_SZIP" = xyes])

View File

@ -27,7 +27,8 @@ typedef struct NC {
void* dispatchdata; /*per-'file' data; points to e.g. NC3_INFO data*/
char* path;
int mode; /* as provided to nc_open/nc_create */
int substrate;
int substrate;
int refcount; /* To enable multiple name-based opens */
} NC;
/*
@ -76,6 +77,7 @@ extern int nc_get_default_format(void);
extern int add_to_NCList(NC*);
extern void del_from_NCList(NC*);/* does not free object */
extern NC* find_in_NCList(int ext_ncid);
extern NC* find_in_NCList_by_name(const char*);
extern void free_NCList(void);/* reclaim whole list */
extern int count_NCList(void); /* return # of entries in NClist */

View File

@ -31,15 +31,10 @@ static struct NCPROTOCOLLIST {
against future changes.
*/
static const char* servers[] = {
"http://thredds-test.ucar.edu",
"http://thredds.ucar.edu",
"http://motherlode.ucar.edu:8081",
"http://motherlode.ucar.edu:8080",
"http://motherlode.ucar.edu",
"http://remotetest.unidata.ucar.edu",
"http://thredds-test.unidata.ucar.edu",
"http://remotetest.ucar.edu",
"http://remotetests.unidata.ucar.edu",
"http://remotetests.ucar.edu",
"http://thredds-test.ucar.edu",
NULL
};

View File

@ -1033,6 +1033,11 @@ nc_abort(int ncid)
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* What to do if refcount > 0? */
/* currently, forcibly abort */
ncp->refcount = 0;
stat = ncp->dispatch->abort(ncid);
del_from_NCList(ncp);
free_NC(ncp);
@ -1085,10 +1090,15 @@ nc_close(int ncid)
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
stat = ncp->dispatch->close(ncid);
/* Remove from the nc list */
del_from_NCList(ncp);
free_NC(ncp);
ncp->refcount--;
if(ncp->refcount <= 0)
{
stat = ncp->dispatch->close(ncid);
/* Remove from the nc list */
del_from_NCList(ncp);
free_NC(ncp);
}
return stat;
}
@ -1505,6 +1515,11 @@ NC_create(const char *path, int cmode, size_t initialsz,
nc_initialized = 1;
}
/* If this path is already open, then fail */
ncp = find_in_NCList_by_name(path);
if(ncp != NULL)
return NC_ENFILE;
if((isurl = NC_testurl(path)))
model = NC_urlmodel(path);
@ -1636,6 +1651,14 @@ NC_open(const char *path, int cmode,
nc_initialized = 1;
}
/* If this path is already open, then bump the refcount and return it */
ncp = find_in_NCList_by_name(path);
if(ncp != NULL) {
ncp->refcount++;
if(ncidp) *ncidp = ncp->ext_ncid;
return NC_NOERR;
}
isurl = NC_testurl(path);
if(isurl)
model = NC_urlmodel(path);

View File

@ -42,6 +42,10 @@ add_to_NCList(NC* ncp)
return NC_ENOMEM;
numfiles = 0;
}
/* Check the refcount */
if(ncp->refcount > 0)
return NC_NOERR;
new_id = 0; /* id's begin at 1 */
for(i=1; i < NCFILELISTLENGTH; i++) {
if(nc_filelist[i] == NULL) {new_id = i; break;}
@ -60,6 +64,10 @@ 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;
/* Check the refcount */
if(ncp->refcount > 0)
return; /* assume caller has decrecmented */
nc_filelist[ncid] = NULL;
numfiles--;
@ -78,3 +86,25 @@ find_in_NCList(int ext_ncid)
return f;
}
/*
Added to support open by name
*/
NC*
find_in_NCList_by_name(const char* path)
{
int i;
NC* f = NULL;
if(nc_filelist == NULL)
return NULL;
for(i=1; i < NCFILELISTLENGTH; i++) {
if(nc_filelist[i] != NULL) {
if(strcmp(nc_filelist[i]->path,path)==0) {
f = nc_filelist[i];
break;
}
}
}
return f;
}

View File

@ -40,10 +40,16 @@ IF(ENABLE_TESTS)
ENDIF()
add_bin_test(ncdap test_nstride_cached)
add_bin_test(ncdap test_partvar)
add_bin_test(ncdap test_varm3)
add_bin_test(ncdap t_auth)
add_bin_test(ncdap t_misc)
# test_varm3 did not survive the transition
# to remotetest.unidata.ucar.edu; the
# coads_climatology.nc file cannot be found.
# Can restore if/when we find that file
# and put it in testdods directory on remotetest.
# add_bin_test(ncdap test_varm3)
ENDIF()
ADD_SUBDIRECTORY(testdata3)
ADD_SUBDIRECTORY(expected3)

View File

@ -34,26 +34,35 @@ endif
test_cvt3_SOURCES = test_cvt.c
test_vara_SOURCES = test_vara.c
test_partvar_SOURCES = test_partvar.c
test_varm3_SOURCES = test_varm3.c
t_dap3a_SOURCES = t_dap3a.c
test_nstride_cached_SOURCE = test_nstride_cached.c
t_auth_SOURCES = t_auth.c
t_misc_SOURCES = t_misc.c
TESTS += t_dap3a test_cvt3 test_vara test_partvar
TESTS += test_varm3
TESTS += t_dap3a
TESTS += test_nstride_cached
TESTS += t_auth
TESTS += t_misc
check_PROGRAMS += t_dap3a test_cvt3 test_vara test_partvar
check_PROGRAMS += test_varm3
check_PROGRAMS += t_dap3a
check_PROGRAMS += test_nstride_cached
check_PROGRAMS += t_auth
check_PROGRAMS += t_misc
# test_varm3 did not survive the transition
# to remotetest.unidata.ucar.edu; the
# coads_climatology.nc file cannot be found.
# Can restore if/when we find that file
# and put it in testdods directory on remotetest.
# test_varm3_SOURCES = test_varm3.c
# check_PROGRAMS += test_varm3
# TESTS += test_varm3
if ENABLE_DAP_AUTH_TESTS
check_PROGRAMS += t_auth
TESTS += t_auth
endif
endif #ENABLE_DAP_REMOTE_TESTS

View File

@ -5,7 +5,7 @@
#include <netcdf.h>
#define URL1 "http://thredds-test.ucar.edu" /* test that no trailing / is ok */
#define URL1 "http://remotetest.unidata.ucar.edu" /* test that no trailing / is ok */
static void
CHECK(int e, const char* msg)

6
ncdump/env Normal file
View File

@ -0,0 +1,6 @@
F="tst_small.nc"
alias q0="./ncdump $F"
alias qh="./ncdump -h $F"
alias qq="gdb --args ./ncdump $F"
alias qqh="gdb --args ./ncdump -h $F"