From 94371d86a9282ed3a2483e40b361a5755e293db7 Mon Sep 17 00:00:00 2001 From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de> Date: Wed, 22 May 2024 10:07:17 +0200 Subject: [PATCH] cdiInqContents: missing lock of non thread-safe netCDF4/HDF5 calls (bug fix) --- ChangeLog | 4 ++++ src/stream.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a88a95094..1c127edfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-05-22 Uwe Schulzweida + + * cdiInqContents: missing lock of non thread-safe netCDF4/HDF5 calls (bug fix) + 2024-05-21 Uwe Schulzweida * Version 2.4.1 released diff --git a/src/stream.c b/src/stream.c index 64402f3db..929cf6124 100644 --- a/src/stream.c +++ b/src/stream.c @@ -380,6 +380,8 @@ streamFilename(int streamID) static int cdiInqContents(stream_t *streamptr) { + if (streamptr->lockIO) CDI_IO_LOCK(); + int status = 0; int filetype = streamptr->filetype; @@ -418,6 +420,8 @@ cdiInqContents(stream_t *streamptr) } } + if (streamptr->lockIO) CDI_IO_UNLOCK(); + if (status == 0) { int taxisID = vlistInqTaxis(streamptr->vlistID); @@ -667,7 +671,7 @@ streamOpenID(const char *filename, char filemode, int filetype, int resH) if (CDI_Threadsafe) { #ifndef HAVE_LIBPTHREAD - Error("CDI threadsafe failed, pthread support not compiled!"); + Error("CDI threadsafe failed, pthread support not compiled in!"); #endif if (filetype == CDI_FILETYPE_NC4 || filetype == CDI_FILETYPE_NC4C) streamptr->lockIO = true; } -- GitLab