summaryrefslogtreecommitdiffstats
path: root/test/vfd_swmr_sparse_writer.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2019-10-23 15:47:14 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2019-10-23 15:47:14 (GMT)
commit0ea6e75d9ff6a62b5e5590dec84df88b781a6e85 (patch)
treed1dc52ab5c87ca799488348807c7457fdab291db /test/vfd_swmr_sparse_writer.c
parente84a416ad85836cdedbe947250f409b6e2c8fbea (diff)
downloadhdf5-0ea6e75d9ff6a62b5e5590dec84df88b781a6e85.zip
hdf5-0ea6e75d9ff6a62b5e5590dec84df88b781a6e85.tar.gz
hdf5-0ea6e75d9ff6a62b5e5590dec84df88b781a6e85.tar.bz2
VFD SWMR sparse readers failed to open the .h5 file because the sparse writer
had finished its work and closed the .h5 file, thus removing the shadow file. Make the sparse writer wait to close the .h5 file for a signal from testvfdswmr.sh. In testvfdswmr.sh, send the signal when the readers have all finished.
Diffstat (limited to 'test/vfd_swmr_sparse_writer.c')
-rw-r--r--test/vfd_swmr_sparse_writer.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/vfd_swmr_sparse_writer.c b/test/vfd_swmr_sparse_writer.c
index 2411c1f..409970b 100644
--- a/test/vfd_swmr_sparse_writer.c
+++ b/test/vfd_swmr_sparse_writer.c
@@ -28,6 +28,8 @@
/***********/
/* Headers */
/***********/
+#include <err.h>
+#include <signal.h>
#include "h5test.h"
#include "vfd_swmr_common.h"
@@ -383,6 +385,48 @@ error:
return -1;
} /* add_records() */
+static volatile sig_atomic_t got_sigusr1 = 0;
+
+static void
+sigusr1_handler(int H5_ATTR_UNUSED signo)
+{
+ got_sigusr1 = 1;
+}
+
+static void
+await_signal(void)
+{
+ sigset_t sleepset, fullset, oldset;
+ struct sigaction sa, osa;
+
+ memset(&sa, '\0', sizeof(sa));
+ sa.sa_handler = sigusr1_handler;
+ if (sigemptyset(&sa.sa_mask) == -1 ||
+ sigfillset(&fullset) == -1 ||
+ sigemptyset(&sleepset) == -1) {
+ err(EXIT_FAILURE, "%s.%d: could not initialize signal masks",
+ __func__, __LINE__);
+ }
+
+ if (sigprocmask(SIG_BLOCK, &fullset, &oldset) == -1)
+ err(EXIT_FAILURE, "%s.%d: sigprocmask", __func__, __LINE__);
+
+ if (sigaction(SIGUSR1, &sa, &osa) == -1)
+ err(EXIT_FAILURE, "%s.%d: sigaction", __func__, __LINE__);
+
+ if (sigsuspend(&sleepset) == -1 && errno != EINTR)
+ err(EXIT_FAILURE, "%s.%d: sigsuspend", __func__, __LINE__);
+
+ if (got_sigusr1 != 0)
+ printf("Cancelled by SIGUSR1.\n");
+
+ if (sigaction(SIGUSR1, &osa, NULL) == -1)
+ err(EXIT_FAILURE, "%s.%d: sigaction", __func__, __LINE__);
+
+ if (sigprocmask(SIG_SETMASK, &oldset, NULL) == -1)
+ err(EXIT_FAILURE, "%s.%d: sigprocmask", __func__, __LINE__);
+}
+
static void
usage(void)
{
@@ -499,6 +543,8 @@ int main(int argc, const char *argv[])
HDexit(1);
} /* end if */
+ await_signal();
+
/* Emit informational message */
if(verbose)
HDfprintf(stderr, "WRITER: Closing objects/file\n");