glib-aux: avoid accessing thread-local variable in a loop

Dunno whether the compiler can optimize this out. Assign to an auto
variable.
This commit is contained in:
Thomas Haller 2021-06-30 23:56:26 +02:00
parent 3649efe2b5
commit 94121a1b48
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -203,7 +203,8 @@ fd_open:
}
if (!urandom_success) {
static _nm_thread_local GRand *rand = NULL;
static _nm_thread_local GRand *rand_tls = NULL;
GRand * rand;
gsize i;
int j;
@ -214,8 +215,10 @@ fd_open:
*/
has_high_quality = FALSE;
rand = rand_tls;
if (G_UNLIKELY(!rand)) {
rand = _rand_create_thread_local();
rand = _rand_create_thread_local();
rand_tls = rand;
nm_utils_thread_local_register_destroy(rand, (GDestroyNotify) g_rand_free);
}