htl: Make pthread_[gs]etspecific not check for key validity

Since __pthread_key_create might be concurrently reallocating the
__pthread_key_destructors array, it's not safe to access it without the
mutex held. Posix explicitly says we are allowed to prefer performance
over error detection.
This commit is contained in:
Samuel Thibault 2022-02-14 00:15:13 +01:00
parent 0fb8800029
commit 315c9e794a
2 changed files with 2 additions and 4 deletions

View File

@ -25,8 +25,7 @@ __pthread_getspecific (pthread_key_t key)
{
struct __pthread *self;
if (key < 0 || key >= __pthread_key_count
|| __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
if (key < 0 || key >= __pthread_key_count)
return NULL;
self = _pthread_self ();

View File

@ -25,8 +25,7 @@ __pthread_setspecific (pthread_key_t key, const void *value)
{
struct __pthread *self = _pthread_self ();
if (key < 0 || key >= __pthread_key_count
|| __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
if (key < 0 || key >= __pthread_key_count)
return EINVAL;
if (key >= self->thread_specifics_size)