Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cb68578

Browse files
committed
Ensure the collator map is thread safe on SortHandle.
1 parent a99bf5f commit cb68578

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/corefx/System.Globalization.Native/collation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ typedef struct _sort_handle
3232
{
3333
UCollator* regular;
3434
TCollatorMap collatorsPerOption;
35+
pthread_mutex_t collatorsLockObject;
3536

3637
_sort_handle() : regular(nullptr)
3738
{
39+
pthread_mutex_init(&collatorsLockObject, NULL);
3840
}
3941

4042
} SortHandle;
@@ -284,6 +286,8 @@ const UCollator* GetCollatorFromSortHandle(SortHandle* pSortHandle, int32_t opti
284286
}
285287
else
286288
{
289+
pthread_mutex_lock(&pSortHandle->collatorsLockObject);
290+
287291
TCollatorMap::iterator entry = pSortHandle->collatorsPerOption.find(options);
288292
if (entry == pSortHandle->collatorsPerOption.end())
289293
{
@@ -294,6 +298,8 @@ const UCollator* GetCollatorFromSortHandle(SortHandle* pSortHandle, int32_t opti
294298
{
295299
pCollator = entry->second;
296300
}
301+
302+
pthread_mutex_unlock(&pSortHandle->collatorsLockObject);
297303
}
298304

299305
return pCollator;

0 commit comments

Comments
 (0)