ICU-10295 Mutex ucln_registerCleanup to clear thread sanitizer errors.

X-SVN-Rev: 35655
This commit is contained in:
Andy Heninger 2014-04-25 17:27:53 +00:00
parent 9c8e20c008
commit 4587ade4b5
3 changed files with 24 additions and 14 deletions

View File

@ -14,12 +14,13 @@
#include "unicode/utypes.h"
#include "unicode/uclean.h"
#include "utracimp.h"
#include "ucln_cmn.h"
#include "cmutex.h"
#include "ucln.h"
#include "cmemory.h"
#include "mutex.h"
#include "uassert.h"
#include "ucln.h"
#include "ucln_cmn.h"
#include "utracimp.h"
#include "umutex.h"
/** Auto-client for UCLN_COMMON **/
#define UCLN_TYPE_IS_COMMON
@ -65,6 +66,7 @@ ucln_common_registerCleanup(ECleanupCommonType type,
U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT);
if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT)
{
icu::Mutex m; // See ticket 10295 for discussion.
gCommonCleanupFunctions[type] = func;
}
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
@ -72,6 +74,10 @@ ucln_common_registerCleanup(ECleanupCommonType type,
#endif
}
// Note: ucln_registerCleanup() is called with the ICU global mutex locked.
// Be aware if adding anything to the function.
// See ticket 10295 for discussion.
U_CAPI void U_EXPORT2
ucln_registerCleanup(ECleanupLibraryType type,
cleanupFunc *func)

View File

@ -16,6 +16,7 @@
#include "ucln.h"
#include "ucln_in.h"
#include "mutex.h"
#include "uassert.h"
/** Auto-client for UCLN_I18N **/
@ -46,13 +47,14 @@ static UBool i18n_cleanup(void)
}
void ucln_i18n_registerCleanup(ECleanupI18NType type,
cleanupFunc *func)
{
cleanupFunc *func) {
U_ASSERT(UCLN_I18N_START < type && type < UCLN_I18N_COUNT);
ucln_registerCleanup(UCLN_I18N, i18n_cleanup);
if (UCLN_I18N_START < type && type < UCLN_I18N_COUNT)
{
gCleanupFunctions[type] = func;
icu::Mutex m; // See ticket 10295 for discussion.
ucln_registerCleanup(UCLN_I18N, i18n_cleanup);
if (UCLN_I18N_START < type && type < UCLN_I18N_COUNT) {
gCleanupFunctions[type] = func;
}
}
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
ucln_registerAutomaticCleanup();

View File

@ -14,6 +14,7 @@
* created by: George Rhoten
*/
#include "mutex.h"
#include "ucln.h"
#include "ucln_io.h"
#include "uassert.h"
@ -51,13 +52,14 @@ static UBool io_cleanup(void)
}
void ucln_io_registerCleanup(ECleanupIOType type,
cleanupFunc *func)
{
cleanupFunc *func) {
U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT);
ucln_registerCleanup(UCLN_IO, io_cleanup);
if (UCLN_IO_START < type && type < UCLN_IO_COUNT)
{
gCleanupFunctions[type] = func;
icu::Mutex m; // See ticket 10295 for discussion.
ucln_registerCleanup(UCLN_IO, io_cleanup);
if (UCLN_IO_START < type && type < UCLN_IO_COUNT) {
gCleanupFunctions[type] = func;
}
}
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))