summaryrefslogtreecommitdiff
path: root/src/network/core/tcp.h
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2020-05-06 23:41:25 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2020-06-18 19:57:34 +0200
commitb0f192abc4e8bdd9f5f46f6932b8308e32b7b4b6 (patch)
treee674c48def6dcf142b798ad015d1ced4d3d460ee /src/network/core/tcp.h
parentc167648d75428e6ff93f903de65df0cab0370bb6 (diff)
downloadopenttd-b0f192abc4e8bdd9f5f46f6932b8308e32b7b4b6.tar.xz
Fix: Racy use of flags in TCPConnecter::CheckCallbacks
conected and aborted flags are used concurrently from multiple threads.
Diffstat (limited to 'src/network/core/tcp.h')
-rw-r--r--src/network/core/tcp.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 08a09ca1a..ffa231497 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -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