fix getBpfSupportLevel() cache wrt. multi-threading
In case it happens to get called twice in parallel on
startup. It's never a mistake to do extra calls to the
uncached version.
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2605ed2ebc4ee331b2ca6c9fa915203d70415d7f
diff --git a/libbpf_android/BpfUtils.cpp b/libbpf_android/BpfUtils.cpp
index c175d98..535c537 100644
--- a/libbpf_android/BpfUtils.cpp
+++ b/libbpf_android/BpfUtils.cpp
@@ -136,14 +136,7 @@
}
BpfLevel getBpfSupportLevel() {
- static bool initialized = false;
- static BpfLevel cache;
-
- if (!initialized) {
- initialized = true;
- cache = getUncachedBpfSupportLevel();
- }
-
+ static BpfLevel cache = getUncachedBpfSupportLevel();
return cache;
}