mirror of
https://github.com/monero-project/monero.git
synced 2024-12-14 04:16:32 +02:00
Add concurrency check to rpc mining to ensure not too many threads. number of cores times 4 or 257.
This commit is contained in:
parent
4629ead8c5
commit
cc1462e0b7
@ -616,6 +616,23 @@ namespace cryptonote
|
|||||||
return true;
|
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;
|
boost::thread::attributes attrs;
|
||||||
attrs.set_stack_size(THREAD_STACK_SIZE);
|
attrs.set_stack_size(THREAD_STACK_SIZE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user