diff options
author | David Young <dyoung@hdfgroup.org> | 2020-04-30 20:26:39 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-04-30 20:26:39 (GMT) |
commit | fdeeac1c1b6c240d172519cd65a8f43378a62630 (patch) | |
tree | c5db3efd5bc7fc4c870381da4bcf72ec752ea281 /test | |
parent | 57e5c4305cb0b741fb28fc7286ae9dd11d4acf56 (diff) | |
download | hdf5-fdeeac1c1b6c240d172519cd65a8f43378a62630.zip hdf5-fdeeac1c1b6c240d172519cd65a8f43378a62630.tar.gz hdf5-fdeeac1c1b6c240d172519cd65a8f43378a62630.tar.bz2 |
Use a one-character buffer to send/receive messages to/from
writer/reader, since that's all we need. Avoid deadlock by flushing the
file before waiting for the reader's message.
Diffstat (limited to 'test')
-rw-r--r-- | test/vfd_swmr_zoo_writer.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index 77cc82d..a0af7d8 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -222,9 +222,7 @@ main(int argc, char **argv) bool print_estack = false; const char *progname = basename(argv[0]); estack_state_t es; -#if 1 - char step[2] = "ab"; -#endif + char step = 'b'; if (strcmp(progname, "vfd_swmr_zoo_writer") == 0) writer = wait_for_signal = true; @@ -314,11 +312,17 @@ main(int argc, char **argv) if (!create_zoo(fid, ".", config)) errx(EXIT_FAILURE, "create_zoo didn't pass self-check"); - if (read(STDIN_FILENO, &step[1], sizeof(step[1])) == -1) + /* Avoid deadlock: flush the file before waiting for the reader's + * message. + */ + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + errx(EXIT_FAILURE, "%s: H5Fflush failed", __func__); + + if (read(STDIN_FILENO, &step, sizeof(step)) == -1) err(EXIT_FAILURE, "read"); - if (step[1] != 'b') - errx(EXIT_FAILURE, "expected 'b' read '%c'", step[1]); + if (step != 'b') + errx(EXIT_FAILURE, "expected 'b' read '%c'", step); if (!delete_zoo(fid, ".", config)) errx(EXIT_FAILURE, "delete_zoo failed"); @@ -328,7 +332,7 @@ main(int argc, char **argv) while (!validate_zoo(fid, ".", config)) ; - if (write(STDOUT_FILENO, &step[1], sizeof(step[1])) == -1) + if (write(STDOUT_FILENO, &step, sizeof(step)) == -1) err(EXIT_FAILURE, "write"); while (!validate_deleted_zoo(fid, ".", config)) ; |