Split H5TS termination into threadlocal/thread-global parts (#4881)

This commit is contained in:
Matt L
2024-10-01 08:38:46 -07:00
committed by GitHub
parent 35adecb94a
commit 62e4777836
2 changed files with 32 additions and 9 deletions
+31 -9
View File
@@ -133,10 +133,12 @@ done:
/*-------------------------------------------------------------------------
* Function: H5TS_term_package
*
* Purpose: Terminate this interface.
* Purpose: Terminate this interface. Clean up global resources shared by
* all threads.
*
* Note: This function is currently registered via atexit() and is called
* AFTER H5_term_library().
* AFTER H5_term_library(). H5TS_top_term_package() is called at library
* termination to clean up per-thread resources.
*
* Return: void
*
@@ -151,9 +153,6 @@ H5TS_term_package(void)
H5TS_mutex_destroy(&H5TS_api_info_p.api_mutex);
H5TS_atomic_destroy_uint(&H5TS_api_info_p.attempt_lock_count);
/* Clean up per-thread library info */
H5TS__tinfo_term();
FUNC_LEAVE_NOAPI_VOID
} /* end H5TS_term_package() */
@@ -535,6 +534,30 @@ H5TS__tinfo_destroy(void *_tinfo_node)
FUNC_LEAVE_NOAPI_VOID_NAMECHECK_ONLY
}
/*--------------------------------------------------------------------------
* Function: H5TS_top_term_package
*
* Purpose: Terminate the threadlocal parts of the H5TS interface during library terminaton.
*
* Note: See H5TS_term_package for termination of the thread-global resources
*
* Return: Non-negative on success / Negative on failure
*
*--------------------------------------------------------------------------
*/
int
H5TS_top_term_package(void)
{
int n = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Clean up per-thread library info */
H5TS__tinfo_term();
FUNC_LEAVE_NOAPI(n)
}
/*--------------------------------------------------------------------------
* Function: H5TS__tinfo_term
*
@@ -562,14 +585,13 @@ H5TS__tinfo_term(void)
if (H5_UNLIKELY(H5TS_mutex_unlock(&H5TS_tinfo_mtx_s) < 0))
HGOTO_DONE(FAIL);
/* Release critical section / mutex for modifying the thread info globals */
if (H5_UNLIKELY(H5TS_mutex_destroy(&H5TS_tinfo_mtx_s) < 0))
HGOTO_DONE(FAIL);
/* Release key for thread-specific API contexts */
if (H5_UNLIKELY(H5TS_key_delete(H5TS_thrd_info_key_g) < 0))
HGOTO_DONE(FAIL);
/* Release critical section / mutex for modifying the thread info globals */
if (H5_UNLIKELY(H5TS_mutex_destroy(&H5TS_tinfo_mtx_s) < 0))
HGOTO_DONE(FAIL);
done:
FUNC_LEAVE_NOAPI_NAMECHECK_ONLY(ret_value)
} /* end H5TS__tinfo_term() */
+1
View File
@@ -276,6 +276,7 @@ typedef atomic_flag H5TS_spinlock_t;
#ifdef H5_HAVE_THREADSAFE
/* Library/thread init/term operations */
H5_DLL void H5TS_term_package(void);
H5_DLL int H5TS_top_term_package(void);
/* API locking */
H5_DLL herr_t H5TS_api_lock(void);