Skip to content

Commit

Permalink
Add locks around connectionClosed modification
Browse files Browse the repository at this point in the history
  • Loading branch information
disa6302 committed Aug 22, 2023
1 parent 83aad05 commit 33239d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/source/Ice/SocketConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ STATUS freeSocketConnection(PSocketConnection* ppSocketConnection)
CHK(ppSocketConnection != NULL, STATUS_NULL_ARG);
pSocketConnection = *ppSocketConnection;
CHK(pSocketConnection != NULL, retStatus);

// connectionClosed is accessed and modified when checking if socket connection is closed
// Hence the modification needs to be protected
MUTEX_LOCK(pSocketConnection->lock);
ATOMIC_STORE_BOOL(&pSocketConnection->connectionClosed, TRUE);
MUTEX_UNLOCK(pSocketConnection->lock);

// Await for the socket connection to be released
shutdownTimeout = GETTIME() + KVS_ICE_TURN_CONNECTION_SHUTDOWN_TIMEOUT;
Expand Down

0 comments on commit 33239d0

Please sign in to comment.