Commit Graph

762 Commits

Author SHA1 Message Date
Ward Fisher
fb75ad6588
Merge pull request #3034 from DennisHeimbigner/minpluginx.dmh
Extend the netcdf API to support programmatic changes to the plugin search path
2024-11-13 01:11:54 +01:00
Ward Fisher
f67f25c57b
Merge pull request #3022 from edwardhartnett/ejh_conf2
fixing some autoconf problems
2024-11-04 17:36:23 +00:00
Dennis Heimbigner
efdec07f3d Extend the netcdf API to support programmatic changes to the plugin search path
Replaces PR https://github.com/Unidata/netcdf-c/pull/3024
         and PR https://github.com/Unidata/netcdf-c/pull/3033

re: https://github.com/Unidata/netcdf-c/issues/2753

As suggested by Ed Hartnett, This PR extends the netcdf.h API to support programmatic control over the search path used to locate plugins.

I created several different APIs, but finally settled on the following API as being the simplest possible. It does have the disadvantage that it requires use of a global lock (not implemented) if used in a threaded environment.

Specifically, note that modifying the plugin path must be done "atomically". That is, in a multi-threaded environment, it is important that the sequence of actions involved in setting up the plugin path must be done by a single processor or in some other way as to guarantee that two or more processors are not simultaneously accessing the plugin path get/set operations.

As an example, assume there exists a mutex lock called PLUGINLOCK. Then any processor accessing the plugin paths should operate as follows:
````
lock(PLUGINLOCK);
nc_plugin_path_get(...);
<rebuild plugin path>
nc_plugin_path_set(...);
unlock(PLUGINLOCK);
````
## Internal Architecture

It is assumed here that there only needs to be a single set of plugin path directories that is shared by all filter code and is independent of any file descriptor; it is global in other words. This means, for example, that the path list for NCZarr and for HDF5 will always be the same.

However internally, processing the set of plugin paths depends on the particular NC_FORMATX value (NC_FORMATX_NC_HDF5 and NC_FORMATX_NCZARR, currently). So the *nc_plugin_path_set* function, will take the paths it is given and propagate them to each of the NC_FORMATX dispatchers to store in a way that is appropriate to the given dispatcher.

There is a complication with respect to the *nc_plugin_path_get* function. It is possible for users to bypass the netcdf API and modify the HDF5 plugin paths directly. This can result in an inconsistent plugin path between the value used by HDF5 and the global value used by netcdf-c. Since there is no obvious fix for this, we warn the user of this possibility and otherwise ignore it.

## Test Changes
* New tests<br>
    a. unit_test/run_pluginpaths.sh -- was created to test this new capability.<br>
    b. A new test utility has been added as *unit_test/run_dfaltpluginpath.sh* to test the default plugin path list.
* New test support utilities<br>
    a. unit_test/ncpluginpath.c -- report current state of the plugin path<br>
    b. unit_test/tst_pluginpaths.c -- test program to support run_pluginpaths.sh

## Documentation
* A new file -- docs/pluginpath.md -- provides documentation of the new API. It includes some
  material taken fro filters.md.

## Other Major Changes
1. Cleanup the whole plugin path decision tree. This is described in the *docs/pluginpath.md* document and summarized in Addendum 2 below.
2. I noticed that the ncdump/testpathcvt.sh had been disabled, so fixed and re-enabled it. This necessitated some significant changes to dpathmgr.c.

## Misc. Changes
1. Add some path manipulation utilities to netcf_aux.h
2. Fix some minor bugs in netcdf_json.h
3. Convert netcdf_json.h and netcdf_proplist.h to BUILT_SOURCE.
4. Add NETCDF_ENABLE_HDF5 as synonym for USE_HDF5
5. Fix some size_t <-> int conversion warnings.
6. Encountered and fixed the Windows \r\n problem in tst_pluginpaths.c.
7. Cleanup some minor CMakeLists.txt problems.
8. Provide an implementation of echo -n since it appears to not be
   available on all platforms.
9. Add a property list mechanism to pass environmental information to filters.
10. Cleanup Doxyfile.in
11. Fixed a memory leak in libdap2; surprised that I did not find this earlier.

## Addendum 1: Proposed API

The API makes use of a counted vector of strings representing the sequence of directories in the path. The relevant type definition is as follows.
````
typedef struct NCPluginList {size_t ndirs; char** dirs;} NCPluginList;
````

The API proposed in this PR looks like this (from netcdf-c/include/netcdf_filter.h).

* ````int nc_plugin_path_ndirs(size_t* ndirsp);````
    Arguments: *ndirsp* -- store the number of directories in this memory.

    This function returns the number of directories in the sequence if internal directories of the internal plugin path list.

* ````int nc_plugin_path_get(NCPluginList* dirs);````
    Arguments:  *dirs* -- counted vector for storing the sequence of directies in the internal path list.

    This function returns the current sequence of directories from the internal plugin path list. Since this function does not modify the plugin path, it does not need to be locked; it is only when used to get the path to be modified that locking is required.  If the value of *dirs.dirs* is NULL (the normal case), then memory is allocated to hold the vector of directories. Otherwise, use the memory of *dirs.dirs* to hold the vector of directories.

* ````int nc_plugin_path_set(const NCPluginList* dirs);````
    Arguments: *dirs* -- counted vector for providing the new sequence of directories in the internal path list.

    This function empties the current internal path sequence and replaces it with the sequence of directories argument. Using an *ndirs* argument of 0 will clear the set of plugin paths.

## Addendum 2: Build-Time and Run-Time Constants.

### Build-Time Constants
<table style="border:2px solid black;border-collapse:collapse">
<tr style="outline: thin solid;" align="center"><td colspan="4">Table showing the build-time computation of NETCDF_PLUGIN_INSTALL_DIR and NETCDF_PLUGIN_SEARCH_PATH.</td>
<tr style="outline: thin solid" ><th>--with-plugin-dir<th>--prefix<th>NETCDF_PLUGIN_INSTALL_DIR<th>NETCDF_PLUGIN_SEARCH_PATH
<tr style="outline: thin solid" ><td>undefined<td>undefined<td>undefined<td>PLATFORMDEFALT
<tr style="outline: thin solid" ><td>undefined<td>&lt;abspath-prefix&gt;<td>&lt;abspath-prefix&gt;/hdf5/lib/plugin<td>&lt;abspath-prefix&gt;/hdf5/lib/plugin&lt;SEP&gt;PLATFORMDEFALT
<tr style="outline: thin solid" ><td>&lt;abspath-plugins&gt;<td>N.A.<td>&lt;abspath-plugins&gt;<td>&lt;abspath-plugins&gt;&lt;SEP&gt;PLATFORMDEFALT
</table>

<table style="border:2px solid black;border-collapse:collapse">
<tr style="outline: thin solid" align="center"><td colspan="2">Table showing the computation of the initial global plugin path</td>
<tr style="outline: thin solid"><th>HDF5_PLUGIN_PATH<th>Initial global plugin path
<tr style="outline: thin solid"><td>undefined<td>NETCDF_PLUGIN_SEARCH_PATH
<tr style="outline: thin solid"><td>&lt;path1;...pathn&gt;<td>&lt;path1;...pathn&gt;
</table>
2024-10-18 19:23:59 -06:00
Dennis Heimbigner
318eb36ad2 Merge branch 'master' into minpluginx.dmh 2024-10-08 12:32:58 -06:00
Ward Fisher
042c0b7cbd Modify nc-config --libs and --static arguments in support of https://github.com/Unidata/netcdf-c/issues/3032 2024-10-01 16:54:38 -05:00
Dennis Heimbigner
ef425b9171 ckp 2024-09-30 14:39:48 -06:00
Ward Fisher
dc0634c6e0 Toggle legacy macros to on, for now. 2024-09-27 14:22:59 -06:00
Ward Fisher
0f92d4c0f6 Clean up a couple of logic errors resulting in github action failures. 2024-09-26 16:52:05 -06:00
Ward Fisher
a222922d7b Add legacy macro option to cmake build system. Changed netcdf_plugin_install_dir to use /usr/local/hdf5/lib/plugin by default unless a 'prefix' is specified by the user, in which case it becomes prefix/hdf5/lib/plugin. This can still be overridden with the build flags appropriate to the build system. 2024-09-25 12:15:55 -05:00
Ward Fisher
de7992c0e0 Add option to enable legacy macros. 2024-09-25 11:34:10 -05:00
Ward Fisher
a7077c6e6e Add configure option to enable potentially-problematic legacy macro _FillValue 2024-09-19 14:56:35 -05:00
Ed
38dcab6567 fixing configure issues 2024-09-12 07:50:07 -06:00
Ed
62a1162ae3 autoconf cleanup 2024-09-12 06:49:48 -06:00
Ward Fisher
6f63ca64b2
Merge pull request #3018 from WardF/fixlibcurl.wif
Check for libcurl should only happen if DAP and/or ncZarr are enabled.
2024-09-11 21:57:32 +00:00
Ward Fisher
36297b0470 Clean up and reorganize a bit, add logic so that byterange support is disabled when the functionality it requires has been disabled. 2024-09-11 16:09:55 -05:00
Ward Fisher
735f5be2d1 Check for libcurl should only happen if DAP and/or ncZarr are enabled. 2024-09-11 14:14:18 -06:00
Ward Fisher
7549bb8b45
Merge branch 'main' into ejh_0830 2024-09-06 12:25:36 -05:00
Edward Hartnett
15c6606513 merged main 2024-09-04 05:26:32 -06:00
Ward Fisher
3d795fafbb
Merge pull request #2996 from edwardhartnett/ejh_t3
adding more zstd testing
2024-09-04 01:34:47 +02:00
Edward Hartnett
9e0ee2790c adding test for HDF5 error message 2024-09-02 05:47:45 -06:00
Ed
9f8132ca51 fixed some autoreconf warnings 2024-08-30 12:58:43 -06:00
Ed
f027bcee30 fixing cmake build 2024-08-30 10:11:12 -06:00
Edward Hartnett
e768bf2cbc parallel zstd test 2024-08-30 05:20:00 -06:00
Ed
774d26a81d fixing findplugins move to h5_test 2024-08-28 14:05:32 -06:00
Ward Fisher
55309972e8 o Added NETCDF_ENABLE_PLUGINS option to cmake based build.
o Added information related to plugins, plugin install location to post-build summary.
2024-08-19 13:47:00 -06:00
Ed
218bf47a08 adding run_zstd_test 2024-08-14 10:24:53 -06:00
Ward Fisher
4aaf312c95
Merge pull request #2973 from edwardhartnett/ejh_fix_configure
fixed --with-plugin-dir option to match cmake behavior
2024-08-13 15:46:38 -06:00
Ed
3bb9aaf430 fixed --with-plugin-dir option to match cmake behavior 2024-08-13 07:44:57 -06:00
Edward Hartnett
c3ae3daf2d Now use H5Literate2() instead of H5Literate() when its available 2024-08-05 07:03:18 -06:00
Ward Fisher
ca36d9940d Merge branch 'main' into v4.9.3-rc1-prep.wif 2024-07-16 15:24:02 -06:00
Ward Fisher
b67745eb0b Correct the check. 2024-07-16 12:42:10 -06:00
Ward Fisher
9012c58edb Fix check for getfattr in configure.ac 2024-07-16 12:36:51 -06:00
Ward Fisher
848e85171a Mitigate extreme slowdown on systems without xattr.h or getfattr. Standard output was being spammed, resulting in a test that currently runs in around a minute to balloon out to almost 20. 2024-07-16 12:19:16 -06:00
Ward Fisher
5f89cd0c10 Fix a hang in cygwin based tests on Windows. Add check for sys/xattr.h so it can be used when available. Added installation of a tool required for cygwin. 2024-07-16 12:05:49 -06:00
Ward Fisher
f29cff2408 Bumped to next version. 2024-06-18 14:15:47 -06:00
Ward Fisher
a63060cd1b Bump SO version according to https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html in preparation for the next release. 2024-06-11 15:36:05 -06:00
Ward Fisher
1a83e12eb3 Clean up surperflous options that will always align with the value of enable-logging 2024-06-06 15:24:13 -06:00
Dennis Heimbigner
fd637fd460 Cleanup handling of NETCDF_ENABLE_SET_LOG_LEVEL and NETCDF_ENABLE_SET_LOG_LEVEL_FUNC
The NETCDF_ENABLE_SET_LOG_LEVEL_FUNC option is apparently not used, but
is effectively used to set NETCDF_ENABLE_SET_LOG_LEVEL.
This is not clear from the build files CMakeLists.txt and configure.ac.
So this PR cleanups the code to make it more clear what is going on.
2024-05-24 16:48:04 -06:00
Dennis Heimbigner
f0f0f39950 Cleanup various Zarr-related build issues
# Description
Remove various obsolete build options. Also do some code movement.

## Specific Changes

* The remotetest server is sometimes unstable, so provide a mechanism
  to force disabling calls to remotetest.unidata.ucar.edu.
  This is enabled by adding a repository variable named
  REMOTETESTDOWN with the value "yes".
* Fix CMakeLists.txt to use the uname command as an alternate
  to using the hostname command (which does not work under cygwin).
* Remove the JNA stuff as obsolete
* Remove the ENABLE_CLIENTSIDE_FILTERS options since it has been
  disabled for a while.
* Fix bad option flag in some github action .yml files: change --disable-xml2 to --disable-libxml2
* Collect globalstate definitions into nc4internal.h
* Remove ENABLE_NCZARR_FILTERS_TESTING option as obsolete and replace
  with ENABLE_NCZARR_FILTERS
* Move some dispatcher independent functions from libsrc4/nc4internal.c to libdispatch/ddispatch.c
* As a long term goal, and because it is now the case that --enable-nczarr
    => USE_NETCDF4, make the external options --enable-netcdf-4 and
    --enable-netcdf4 obsolete in favor of --enable-hdf5
    We will do the following for one more release cycle.
        1. Make --enable-netcdf-4 be an alias for --enable-netcdf4.
        2. Make --enable-netcdf4 an alias for --enable-hdf5.
        3. Internally, convert most uses of USE_NETCDF_4 ad USE_NETCDF4 to USE_HDF5
    After the next release, --enable-netcdf-4 and --enable-netcdf4 will
    be removed.
2024-05-15 18:46:25 -06:00
Jennifer Oxelson
ef5fcf962b ftp --> resources 2024-05-13 16:50:50 -06:00
Dennis Heimbigner
69ed78e7d7 Convert the ENABLE_XXX options to NETCDF_ENABLE_XXX options
# Primary Change
In order to conform to the cmake overhaul, occurrences of
ENABLE_XXX options in the nczarr code have been changed to
NETCDF_ENABLE_XXX.

# Misc. Other changes
* Fix use of rand_s in libdispatch/ncrandom.c
* Fix some bugs in the mingw gitub action.
* Fix signature bug in libncpoco/cp_win32.c
* Make some NCZarr fixes to config.h.cmake.in
2024-05-11 16:23:40 -06:00
Kyle Shores
8fd6dcb979 Replace ENABLE_S3 with NETCDF_ENABLE_S3 2024-03-18 15:54:15 -05:00
Kyle Shores
85f697868c Replace ENABLE_QUANTIZE with NETCDF_ENABLE_QUANTIZE 2024-03-18 15:54:07 -05:00
Kyle Shores
44778e52bf Replace ENABLE_PLUGINS with NETCDF_ENABLE_PLUGINS 2024-03-18 15:53:59 -05:00
Kyle Shores
d1334f7b88 Replace ENABLE_NCZARR with NETCDF_ENABLE_NCZARR 2024-03-18 15:52:19 -05:00
Kyle Shores
9584b4fa3b Replace ENABLE_LIBXML2 with NETCDF_ENABLE_LIBXML2 2024-03-18 15:52:09 -05:00
Kyle Shores
c5f24df396 Replace ENABLE_HDF5 with NETCDF_ENABLE_HDF5 2024-03-18 15:52:02 -05:00
Kyle Shores
0535edd9c1 Replace ENABLE_FILTER_TESTING with NETCDF_ENABLE_FILTER_TESTING 2024-03-18 15:51:55 -05:00
Kyle Shores
6d1bae4de9 Replace ENABLE_EXTERNAL_SERVER_TESTS with NETCDF_ENABLE_EXTERNAL_SERVER_TESTS 2024-03-18 15:51:35 -05:00
Kyle Shores
831bf665ce Replace ENABLE_DOXYGEN with NETCDF_ENABLE_DOXYGEN 2024-03-18 15:51:24 -05:00