aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-02-02 21:12:13 +0200
committerRiccardo Spagni <ric@spagni.net>2017-02-02 21:12:13 +0200
commit72aa788a0ea7ff7e3c328e84c77f654ecbfe559a (patch)
treeb032e0b102c0e35dbf6be33e7d679bbfd4bde85c /src/rpc/core_rpc_server.cpp
parentMerge pull request #1634 (diff)
parentAdd concurrency check to rpc mining to ensure not too many threads. number of... (diff)
downloadmonero-72aa788a0ea7ff7e3c328e84c77f654ecbfe559a.tar.xz
Merge pull request #1636
cc1462e0 Add concurrency check to rpc mining to ensure not too many threads. number of cores times 4 or 257. (Ashley Perpetual)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-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 63f2b7e53..b2e8e6716 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -615,6 +615,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);