summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-03-12 17:27:57 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-03-12 17:27:57 (GMT)
commit9e81f0103cdd862140fe66fabadf2107deb93152 (patch)
tree864bc6d18d26a8db3b65b4fc247278b14d978f75
parent9592b80913e775322b0308702b5776ee8d70b7cf (diff)
downloadhdf5-9e81f0103cdd862140fe66fabadf2107deb93152.zip
hdf5-9e81f0103cdd862140fe66fabadf2107deb93152.tar.gz
hdf5-9e81f0103cdd862140fe66fabadf2107deb93152.tar.bz2
Add disable_estack() and restore_estack() for disabling the current error-stack
handling and restoring the previous error-stack handling.
-rw-r--r--test/vfd_swmr_common.c26
-rw-r--r--test/vfd_swmr_common.h16
2 files changed, 33 insertions, 9 deletions
diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c
index 6db9bfa..f6156fe 100644
--- a/test/vfd_swmr_common.c
+++ b/test/vfd_swmr_common.c
@@ -29,6 +29,23 @@
#include "h5test.h"
#include "vfd_swmr_common.h"
+estack_state_t
+disable_estack(void)
+{
+ estack_state_t es;
+
+ (void)H5Eget_auto(H5E_DEFAULT, &es.efunc, &es.edata);
+ (void)H5Eset_auto(H5E_DEFAULT, NULL, NULL);
+
+ return es;
+}
+
+void
+restore_estack(estack_state_t es)
+{
+ (void)H5Eset_auto(H5E_DEFAULT, es.efunc, es.edata);
+}
+
void
block_signals(sigset_t *oldset)
{
@@ -57,6 +74,7 @@ await_signal(hid_t fid)
struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100};
if (sigemptyset(&sleepset) == -1 ||
+ sigaddset(&sleepset, SIGINT) == -1 ||
sigaddset(&sleepset, SIGUSR1) == -1) {
err(EXIT_FAILURE, "%s.%d: could not initialize signal masks",
__func__, __LINE__);
@@ -69,8 +87,7 @@ await_signal(hid_t fid)
printf("Received SIGUSR1, wrapping things up.\n");
break;
} else if (rc == -1 && errno == EAGAIN) {
- H5E_auto_t efunc;
- void *edata;
+ estack_state_t es;
/* Avoid deadlock with peer: periodically enter the API so that
* tick processing occurs and data is flushed so that the peer
@@ -79,11 +96,10 @@ await_signal(hid_t fid)
* The call we make will fail, but that's ok,
* so squelch errors.
*/
- (void)H5Eget_auto(H5E_DEFAULT, &efunc, &edata);
- (void)H5Eset_auto(H5E_DEFAULT, NULL, NULL);
+ es = disable_estack();
(void)H5Aexists_by_name(fid, "nonexistent", "nonexistent",
H5P_DEFAULT);
- (void)H5Eset_auto(H5E_DEFAULT, efunc, edata);
+ restore_estack(es);
} else if (rc == -1)
err(EXIT_FAILURE, "%s: sigtimedwait", __func__);
}
diff --git a/test/vfd_swmr_common.h b/test/vfd_swmr_common.h
index e3a563f..ac08503 100644
--- a/test/vfd_swmr_common.h
+++ b/test/vfd_swmr_common.h
@@ -43,6 +43,11 @@
/* Typedefs */
/************/
+typedef struct _estack_state {
+ H5E_auto_t efunc;
+ void *edata;
+} estack_state_t;
+
/* Information about a symbol/dataset */
typedef struct {
char *name; /* Dataset name for symbol */
@@ -69,6 +74,9 @@ H5TEST_DLLVAR unsigned symbol_count[NLEVELS];
extern "C" {
#endif
+H5TEST_DLL estack_state_t disable_estack(void);
+H5TEST_DLL void restore_estack(estack_state_t);
+
H5TEST_DLL symbol_info_t * choose_dataset(unsigned *, unsigned *);
H5TEST_DLL hid_t create_symbol_datatype(void);
H5TEST_DLL int generate_name(char *name_buf, unsigned level, unsigned count);
@@ -76,12 +84,12 @@ H5TEST_DLL int generate_symbols(void);
H5TEST_DLL int shutdown_symbols(void);
H5TEST_DLL int print_metadata_retries_info(hid_t fid);
-#ifdef __cplusplus
-}
-#endif
-
H5TEST_DLL void block_signals(sigset_t *);
H5TEST_DLL void restore_signals(sigset_t *);
H5TEST_DLL void await_signal(hid_t);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _SWMR_COMMON_H */