diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-03 00:04:42 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-03 00:04:42 (GMT) |
commit | 99237a729181c4143c91cf333575f27befd9cff3 (patch) | |
tree | c81b7db0749487dda4fcea26f5a225584938ee04 | |
parent | c7518ef2995ed060761c375223e797ea2f8c24bf (diff) | |
download | hdf5-99237a729181c4143c91cf333575f27befd9cff3.zip hdf5-99237a729181c4143c91cf333575f27befd9cff3.tar.gz hdf5-99237a729181c4143c91cf333575f27befd9cff3.tar.bz2 |
Switch to using H5_nanosleep() instead of HDnanosleep()
* Just in the main library and test/vfd_swmr.c
* VFD SWMR acceptance tests still use HDnanosleep() directly
-rw-r--r-- | src/H5Fvfd_swmr.c | 26 | ||||
-rw-r--r-- | test/vfd_swmr.c | 12 |
2 files changed, 9 insertions, 29 deletions
diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 1ff9ef7..76748fe 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1916,39 +1916,25 @@ H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) struct timespec req; struct timespec rem; uint64_t tick_in_nsec; - H5F_shared_t *shared = f->shared; + H5F_shared_t *shared; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC + HDassert(f); + shared = f->shared; HDassert(shared->vfd_swmr); HDassert(shared->vfd_swmr_writer); tick_in_nsec = shared->vfd_swmr_config.tick_len * nanosecs_per_tenth_sec; - req.tv_nsec = (long)(tick_in_nsec % nanosecs_per_second); - req.tv_sec = (time_t)(tick_in_nsec / nanosecs_per_second); - - result = HDnanosleep(&req, &rem); - - while ( result == -1 ) { - - req = rem; - result = HDnanosleep(&req, &rem); - } - if ( result != 0 ) + H5_nanosleep(tick_in_nsec); - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "HDnanosleep() failed.") - - if ( H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0 ) - - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ - "H5F_vfd_swmr_writer_end_of_tick() failed.") + if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5F__vfd_swmr_writer__wait_a_tick() */ herr_t diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 321f85f..09188f6 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -824,19 +824,13 @@ error: return 1; } /* test_writer_create_open_flush() */ -/* Sleep for `tenths` tenths of a second. - * - * This routine may quietly perform a too-short sleep if an error occurs - * in nanosleep(2). - */ +/* Sleep for `tenths` tenths of a second */ static void decisleep(uint32_t tenths) { - struct timespec delay = {.tv_sec = tenths / 10, - .tv_nsec = tenths * 100 * 1000 * 1000}; + uint64_t nsec = tenths * 100 * 1000 * 1000; - while (HDnanosleep(&delay, &delay) == -1 && errno == EINTR) - ; // do nothing + H5_nanosleep(nsec); } |