diff options
author | Grant Limberg <grant.limberg@zerotier.com> | 2018-12-07 00:59:08 -0800 |
---|---|---|
committer | Grant Limberg <grant.limberg@zerotier.com> | 2018-12-07 00:59:08 -0800 |
commit | 4a89729529b721f7c81548e8df6b3e01a20179c4 (patch) | |
tree | d718481e436b9d39b5d43e5bb5d705a32d5b1630 /service | |
parent | 56a58f2b11d72a3c44eb124cc00b6ec0dd1ddda4 (diff) | |
download | infinitytier-4a89729529b721f7c81548e8df6b3e01a20179c4.tar.gz infinitytier-4a89729529b721f7c81548e8df6b3e01a20179c4.zip |
add INCOMING_PACKET_CONCURRENCY environment variable to be able to specify max threads for receive in controller
Diffstat (limited to 'service')
-rw-r--r-- | service/OneService.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index 1351cbfb..2223b9a8 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -607,7 +607,17 @@ public: _ports[1] = 0; _ports[2] = 0; - _incomingPacketConcurrency = std::max((unsigned long)1,std::min((unsigned long)16,(unsigned long)std::thread::hardware_concurrency())); + char *envPool = std::getenv("INCOMING_PACKET_CONCURRENCY"); + if (envPool != NULL) { + int tmp = atoi(envPool); + if (tmp > 0) { + _incomingPacketConcurrency = tmp; + } else { + _incomingPacketConcurrency = std::max((unsigned long)1,std::min((unsigned long)16,(unsigned long)std::thread::hardware_concurrency())); + } + } else { + _incomingPacketConcurrency = std::max((unsigned long)1,std::min((unsigned long)16,(unsigned long)std::thread::hardware_concurrency())); + } for(long t=0;t<_incomingPacketConcurrency;++t) { _incomingPacketThreads.push_back(std::thread([this]() { OneServiceIncomingPacket *pkt = nullptr; |