Fix: Racy use of flags in TCPConnecter::CheckCallbacks

conected and aborted flags are used concurrently from multiple threads.
This commit is contained in:
Jonathan G Rennison
2020-05-06 23:41:25 +01:00
committed by Niels Martin Hansen
parent c167648d75
commit b0f192abc4
2 changed files with 9 additions and 5 deletions

View File

@@ -15,6 +15,8 @@
#include "address.h"
#include "packet.h"
#include <atomic>
/** The states of sending the packets. */
enum SendPacketsState {
SPS_CLOSED, ///< The connection got closed.
@@ -61,8 +63,8 @@ public:
*/
class TCPConnecter {
private:
bool connected; ///< Whether we succeeded in making the connection
bool aborted; ///< Whether we bailed out (i.e. connection making failed)
std::atomic<bool> connected;///< Whether we succeeded in making the connection
std::atomic<bool> aborted; ///< Whether we bailed out (i.e. connection making failed)
bool killed; ///< Whether we got killed
SOCKET sock; ///< The socket we're connecting with