diff options
author | 2018-03-14 14:16:50 -0700 | |
---|---|---|
committer | 2018-03-14 14:16:50 -0700 | |
commit | 3681ca350bca5b022d82a986f6e855ac7d85b319 (patch) | |
tree | 8e9819d7d73ad1947d66310912fce15df974b8ca /src | |
parent | ac872dd656c08ac4be640a834530cb7dec709a1a (diff) | |
parent | 0b4361c1b7c987dc2de4f15eb32dbe87994f07d9 (diff) |
Merge pull request #14712 from yashykt/hotplugcpu
Add checking for hotplugged CPUs in gpr_cpu_current_cpu for linux
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/gpr/cpu_linux.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/lib/gpr/cpu_linux.cc b/src/core/lib/gpr/cpu_linux.cc index fda28916f8..9fc2f0b141 100644 --- a/src/core/lib/gpr/cpu_linux.cc +++ b/src/core/lib/gpr/cpu_linux.cc @@ -71,6 +71,10 @@ unsigned gpr_cpu_current_cpu(void) { gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno)); return 0; } + if (static_cast<unsigned>(cpu) >= gpr_cpu_num_cores()) { + gpr_log(GPR_ERROR, "Cannot handle hot-plugged CPUs"); + return 0; + } return static_cast<unsigned>(cpu); #endif } |