From f931654d48265dcd54ce7a6e80657d0f5d0cd8cb Mon Sep 17 00:00:00 2001 From: dgelessus Date: Tue, 19 Sep 2023 22:38:41 +0200 Subject: [PATCH] Lock s_critsect in AbandonConn to be safe Not completely sure if this is actually necessary, but all other code that uses the abandoned and cancelId fields also holds s_critsect. Currently, all callers of AbandonConn already have s_critsect locked, but this is clearer and safer in case the calling code changes. Co-authored-by: Adam Johnson --- Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp | 1 + Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp | 1 + Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp | 1 + .../Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index bbab8994cb..61fde8e31f 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -1327,6 +1327,7 @@ static CliAuConn * GetConnIncRef (const char tag[]) { //============================================================================ static void AbandonConn(CliAuConn* conn) { + hsLockGuard(s_critsect); conn->abandoned = true; conn->StopAutoReconnect(); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index dff93c44a2..ad12f99dac 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -275,6 +275,7 @@ static CliFileConn * GetConnIncRef (const char tag[]) { //============================================================================ static void AbandonConn(CliFileConn* conn) { + hsLockGuard(s_critsect); conn->abandoned = true; if (conn->AutoReconnectEnabled()) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index e3a6e8c69f..cd5a2972fc 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -193,6 +193,7 @@ static CliGmConn * GetConnIncRef (const char tag[]) { //============================================================================ static void AbandonConn(CliGmConn* conn) { + hsLockGuard(s_critsect); conn->abandoned = true; if (conn->cancelId) { AsyncSocketConnectCancel(conn->cancelId); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 642ad50954..79233a57e5 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -220,6 +220,7 @@ static CliGkConn * GetConnIncRef (const char tag[]) { //============================================================================ static void AbandonConn(CliGkConn* conn) { + hsLockGuard(s_critsect); conn->abandoned = true; conn->StopAutoReconnect();