mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 08:50:07 +01:00
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:
parent
3649efe2b5
commit
94121a1b48
1 changed files with 5 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue