aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-03-14 11:49:12 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2018-03-14 11:49:12 -0700
commit0b4361c1b7c987dc2de4f15eb32dbe87994f07d9 (patch)
tree9cd2e85a87613ecbffe127f98dd7495406ff18fc /src
parentb62d77f05b158291061637984e0197475c3e8f1a (diff)
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.cc4
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
}