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)
This commit is contained in:
Riccardo Spagni 2017-02-02 21:12:13 +02:00
commit 72aa788a0e
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 17 additions and 0 deletions

View File

@ -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);