aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAshley Perpetual <ashleyperpetual@gmail.com>2017-01-27 03:31:56 +0800
committerAshley Perpetual <ashleyperpetual@gmail.com>2017-01-28 05:59:56 +0800
commitcc1462e0b7cc111943a2a3c7d525b362aca8a40a (patch)
tree6f798cace9bc7d5a395bc5f72df09e32060faee5 /src
parentMerge pull request #1618 (diff)
downloadmonero-cc1462e0b7cc111943a2a3c7d525b362aca8a40a.tar.xz
Add concurrency check to rpc mining to ensure not too many threads. number of cores times 4 or 257.
Diffstat (limited to 'src')
-rw-r--r--src/rpc/core_rpc_server.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 7d896e491..9782c7b83 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -616,6 +616,23 @@ namespace cryptonote
return true;
}
+ unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4;
+
+ // if we couldn't detect threads, set it to a ridiculously high number
+ if(concurrency_count == 0)
+ {
+ concurrency_count = 257;
+ }
+
+ // if there are more threads requested than the hardware supports
+ // then we fail and log that.
+ if(req.threads_count > concurrency_count)
+ {
+ res.status = "Failed, too many threads relative to CPU cores.";
+ LOG_PRINT_L0(res.status);
+ return true;
+ }
+
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);