From a0c78da1ad3e388da219a7d3f065d43d4118b898 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 18 Nov 2020 22:54:05 -0500 Subject: [PATCH] Revert "Tune thread count based on hardware concurrency." This reverts commit 7b14aeb53e20727d304f97de33739c69770f2119. --- osdep/LinuxEthernetTap.cpp | 12 ++++++------ osdep/LinuxEthernetTap.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index aeffede06..8a557c077 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -184,14 +184,14 @@ LinuxEthernetTap::LinuxEthernetTap( (void)::pipe(_shutdownSignalPipe); - for(unsigned int tn=0,tc=(unsigned int)std::thread::hardware_concurrency();tn<=tc;++tn) { - _tapReaderThreads.push_back(std::thread([this, tn]{ + for(unsigned int t=0;t<2;++t) { + _tapReaderThread[t] = std::thread([this, t]{ fd_set readfds,nullfds; int n,nfds,r; void *buf = nullptr; std::vector buffers; - if (tn == 0) { + if (t == 0) { struct ifreq ifr; memset(&ifr,0,sizeof(ifr)); strcpy(ifr.ifr_name,_dev.c_str()); @@ -298,7 +298,7 @@ LinuxEthernetTap::LinuxEthernetTap( } } } - })); + }); } _tapProcessorThread = std::thread([this] { @@ -331,8 +331,8 @@ LinuxEthernetTap::~LinuxEthernetTap() ::close(_shutdownSignalPipe[0]); ::close(_shutdownSignalPipe[1]); - for(std::vector::iterator t(_tapReaderThreads.begin());t!=_tapReaderThreads.end();++t) - t->join(); + _tapReaderThread[0].join(); + _tapReaderThread[1].join(); _tapProcessorThread.join(); for(std::vector::iterator i(_buffers.begin());i!=_buffers.end();++i) diff --git a/osdep/LinuxEthernetTap.hpp b/osdep/LinuxEthernetTap.hpp index 8a3890bcb..a21a53a2c 100644 --- a/osdep/LinuxEthernetTap.hpp +++ b/osdep/LinuxEthernetTap.hpp @@ -70,7 +70,7 @@ private: int _fd; int _shutdownSignalPipe[2]; std::atomic_bool _enabled; - std::vector _tapReaderThreads; + std::thread _tapReaderThread[2]; std::thread _tapProcessorThread; std::mutex _buffers_l; std::vector _buffers;