mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Limit the number of threads to 127 (#1111)
This commit is contained in:
parent
a71d413202
commit
622dc8676a
2 changed files with 16 additions and 8 deletions
|
@ -1231,15 +1231,19 @@ int main(int argc, char *argv[]) {
|
|||
});
|
||||
td::uint32 threads = 7;
|
||||
p.add_checked_option(
|
||||
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
|
||||
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice arg) {
|
||||
td::int32 v;
|
||||
try {
|
||||
v = std::stoi(fname.str());
|
||||
v = std::stoi(arg.str());
|
||||
} catch (...) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
|
||||
}
|
||||
if (v < 1 || v > 256) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
|
||||
if (v <= 0) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be > 0");
|
||||
}
|
||||
if (v > 127) {
|
||||
LOG(WARNING) << "`--threads " << v << "` is too big, effective value will be 127";
|
||||
v = 127;
|
||||
}
|
||||
threads = v;
|
||||
return td::Status::OK();
|
||||
|
|
|
@ -4157,15 +4157,19 @@ int main(int argc, char *argv[]) {
|
|||
});
|
||||
td::uint32 threads = 7;
|
||||
p.add_checked_option(
|
||||
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
|
||||
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice arg) {
|
||||
td::int32 v;
|
||||
try {
|
||||
v = std::stoi(fname.str());
|
||||
v = std::stoi(arg.str());
|
||||
} catch (...) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
|
||||
}
|
||||
if (v < 1 || v > 256) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
|
||||
if (v <= 0) {
|
||||
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be > 0");
|
||||
}
|
||||
if (v > 127) {
|
||||
LOG(WARNING) << "`--threads " << v << "` is too big, effective value will be 127";
|
||||
v = 127;
|
||||
}
|
||||
threads = v;
|
||||
return td::Status::OK();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue