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 e6c916f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion src/source/Ice/TurnConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ STATUS turnConnectionStepState(PTurnConnection pTurnConnection)
}

CHK_STATUS(turnConnectionFreePreAllocatedPackets(pTurnConnection));
if(pTurnConnection != NULL) {
if (pTurnConnection != NULL) {
CHK_STATUS(socketConnectionClosed(pTurnConnection->pControlChannel));
}
pTurnConnection->state = STATUS_SUCCEEDED(pTurnConnection->errorStatus) ? TURN_STATE_NEW : TURN_STATE_FAILED;
Expand Down

0 comments on commit e6c916f

Please sign in to comment.