diff options
author | Thomas Haller <thaller@redhat.com> | 2021-06-30 23:56:26 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-07-05 14:51:27 +0200 |
commit | 94121a1b48b67ede0ebe8dec336da18e05d403eb (patch) | |
tree | 51dbe4df68d6265415b1fb7538a6ebd69c47290b | |
parent | 3649efe2b574866f0a9fb5e38f368408b1547697 (diff) | |
download | NetworkManager-94121a1b48b67ede0ebe8dec336da18e05d403eb.tar.gz |
glib-aux: avoid accessing thread-local variable in a loop
Dunno whether the compiler can optimize this out. Assign to an auto
variable.
-rw-r--r-- | src/libnm-glib-aux/nm-random-utils.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libnm-glib-aux/nm-random-utils.c b/src/libnm-glib-aux/nm-random-utils.c index 8c364cb543..f622b28411 100644 --- a/src/libnm-glib-aux/nm-random-utils.c +++ b/src/libnm-glib-aux/nm-random-utils.c @@ -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); } |