mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Shutdown fix.
This commit is contained in:
parent
a390629371
commit
11545bdb5d
2 changed files with 7 additions and 2 deletions
|
@ -92,7 +92,8 @@ LinuxEthernetTap::LinuxEthernetTap(
|
||||||
_homePath(homePath),
|
_homePath(homePath),
|
||||||
_mtu(mtu),
|
_mtu(mtu),
|
||||||
_fd(0),
|
_fd(0),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_running(true)
|
||||||
{
|
{
|
||||||
static std::mutex s_tapCreateLock;
|
static std::mutex s_tapCreateLock;
|
||||||
char procpath[128],nwids[32];
|
char procpath[128],nwids[32];
|
||||||
|
@ -267,7 +268,7 @@ LinuxEthernetTap::LinuxEthernetTap(
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else if ((errno != EINTR)||(!_running.load())) {
|
||||||
r = 0;
|
r = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -297,9 +298,12 @@ LinuxEthernetTap::LinuxEthernetTap(
|
||||||
|
|
||||||
LinuxEthernetTap::~LinuxEthernetTap()
|
LinuxEthernetTap::~LinuxEthernetTap()
|
||||||
{
|
{
|
||||||
|
_running = false;
|
||||||
|
|
||||||
_tapq.post(std::pair<void *,int>(nullptr,0));
|
_tapq.post(std::pair<void *,int>(nullptr,0));
|
||||||
::shutdown(_fd, SHUT_RDWR);
|
::shutdown(_fd, SHUT_RDWR);
|
||||||
::close(_fd);
|
::close(_fd);
|
||||||
|
pthread_kill(_tapReaderThread.native_handle(), SIGUSR1);
|
||||||
|
|
||||||
_tapReaderThread.join();
|
_tapReaderThread.join();
|
||||||
_tapProcessorThread.join();
|
_tapProcessorThread.join();
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
unsigned int _mtu;
|
unsigned int _mtu;
|
||||||
int _fd;
|
int _fd;
|
||||||
std::atomic_bool _enabled;
|
std::atomic_bool _enabled;
|
||||||
|
std::atomic_bool _running;
|
||||||
std::thread _tapReaderThread;
|
std::thread _tapReaderThread;
|
||||||
std::thread _tapProcessorThread;
|
std::thread _tapProcessorThread;
|
||||||
std::mutex _buffers_l;
|
std::mutex _buffers_l;
|
||||||
|
|
Loading…
Add table
Reference in a new issue