mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-21 03:55:19 +00:00
Fix a problem that made valgrind complain on shutdown (not otherwise an issue).
This commit is contained in:
parent
63a51e2890
commit
16bc9533ed
@ -37,6 +37,7 @@ DeferredPackets::DeferredPackets(const RuntimeEnvironment *renv) :
|
|||||||
RR(renv),
|
RR(renv),
|
||||||
_readPtr(0),
|
_readPtr(0),
|
||||||
_writePtr(0),
|
_writePtr(0),
|
||||||
|
_waiting(0),
|
||||||
_die(false)
|
_die(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -45,8 +46,11 @@ DeferredPackets::~DeferredPackets()
|
|||||||
{
|
{
|
||||||
_q_m.lock();
|
_q_m.lock();
|
||||||
_die = true;
|
_die = true;
|
||||||
_q_m.unlock();
|
while (_waiting > 0) {
|
||||||
_q_s.post();
|
_q_m.unlock();
|
||||||
|
_q_s.post();
|
||||||
|
_q_m.lock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeferredPackets::enqueue(IncomingPacket *pkt)
|
bool DeferredPackets::enqueue(IncomingPacket *pkt)
|
||||||
@ -72,16 +76,16 @@ int DeferredPackets::process()
|
|||||||
_q_m.lock();
|
_q_m.lock();
|
||||||
if (_die) {
|
if (_die) {
|
||||||
_q_m.unlock();
|
_q_m.unlock();
|
||||||
_q_s.post();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while (_readPtr == _writePtr) {
|
while (_readPtr == _writePtr) {
|
||||||
|
++_waiting;
|
||||||
_q_m.unlock();
|
_q_m.unlock();
|
||||||
_q_s.wait();
|
_q_s.wait();
|
||||||
_q_m.lock();
|
_q_m.lock();
|
||||||
|
--_waiting;
|
||||||
if (_die) {
|
if (_die) {
|
||||||
_q_m.unlock();
|
_q_m.unlock();
|
||||||
_q_s.post();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ private:
|
|||||||
const RuntimeEnvironment *const RR;
|
const RuntimeEnvironment *const RR;
|
||||||
unsigned long _readPtr;
|
unsigned long _readPtr;
|
||||||
unsigned long _writePtr;
|
unsigned long _writePtr;
|
||||||
bool _die;
|
volatile int _waiting;
|
||||||
|
volatile bool _die;
|
||||||
Mutex _q_m;
|
Mutex _q_m;
|
||||||
BinarySemaphore _q_s;
|
BinarySemaphore _q_s;
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
#ifdef ZT_ENABLE_CLUSTER
|
#ifdef ZT_ENABLE_CLUSTER
|
||||||
,cluster((Cluster *)0)
|
,cluster((Cluster *)0)
|
||||||
#endif
|
#endif
|
||||||
,dpEnabled(false)
|
,dpEnabled(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user