Change how Dispatcher is shut down.

The previous use of a timeout resulting in thread detach instead of thread
join resulted in a race condition on Mac between destruction and thread
closeout.  This commit removes the detach functionality and uses dup2() to
on Linux/Mac and connecting to itself on Windows to try to ensure accept()
exits.
This commit is contained in:
Peter Johnson
2015-12-22 08:23:44 -08:00
parent 2540f102b0
commit 44821c3e3c
4 changed files with 57 additions and 65 deletions

View File

@@ -24,6 +24,7 @@
#ifndef TCPSOCKETS_TCPACCEPTOR_H_
#define TCPSOCKETS_TCPACCEPTOR_H_
#include <atomic>
#include <memory>
#include <string>
@@ -35,7 +36,7 @@ class TCPAcceptor : public NetworkAcceptor {
int m_port;
std::string m_address;
bool m_listening;
bool m_shutdown;
std::atomic_bool m_shutdown;
public:
TCPAcceptor(int port, const char* address);