Merge "make getBpfSupportLevel() cached"
This commit is contained in:
commit
61588e0e64
1 changed files with 13 additions and 1 deletions
|
|
@ -106,7 +106,7 @@ std::string BpfLevelToString(BpfLevel bpfLevel) {
|
|||
}
|
||||
}
|
||||
|
||||
BpfLevel getBpfSupportLevel() {
|
||||
static BpfLevel getUncachedBpfSupportLevel() {
|
||||
struct utsname buf;
|
||||
int kernel_version_major;
|
||||
int kernel_version_minor;
|
||||
|
|
@ -135,5 +135,17 @@ BpfLevel getBpfSupportLevel() {
|
|||
return BpfLevel::NONE;
|
||||
}
|
||||
|
||||
BpfLevel getBpfSupportLevel() {
|
||||
static bool initialized = false;
|
||||
static BpfLevel cache;
|
||||
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
cache = getUncachedBpfSupportLevel();
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
} // namespace bpf
|
||||
} // namespace android
|
||||
|
|
|
|||
Loading…
Reference in a new issue