Skip to content

Commit

Permalink
Cleanup freeing of KvsPeerConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankiesz committed Nov 12, 2024
1 parent 35e2b88 commit 8b37424
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,38 +1119,34 @@ STATUS freePeerConnection(PRtcPeerConnection* ppPeerConnection)
if (pKvsPeerConnection->pTwccManager != NULL) {
MUTEX_LOCK(pKvsPeerConnection->twccLock);
twccLocked = TRUE;

if (STATUS_SUCCEEDED(hashTableGetCount(pKvsPeerConnection->pTwccManager->pTwccRtpPktInfosHashTable, &twccHashTableCount))) {
DLOGI("Number of TWCC info packets in memory: %d", twccHashTableCount);
}

CHK_LOG_ERR(hashTableIterateEntries(pKvsPeerConnection->pTwccManager->pTwccRtpPktInfosHashTable, 0, freeHashEntry));
CHK_LOG_ERR(hashTableFree(pKvsPeerConnection->pTwccManager->pTwccRtpPktInfosHashTable));
if (IS_VALID_MUTEX_VALUE(pKvsPeerConnection->twccLock)) {
if (twccLocked) {
MUTEX_UNLOCK(pKvsPeerConnection->twccLock);
twccLocked = FALSE;
}
MUTEX_FREE(pKvsPeerConnection->twccLock);
pKvsPeerConnection->twccLock = INVALID_MUTEX_VALUE;
}

SAFE_MEMFREE(pKvsPeerConnection->pTwccManager);
}

// Incase the `RemoteSessionDescription` has not already been freed.
SAFE_MEMFREE(pKvsPeerConnection->pRemoteSessionDescription);

PROFILE_WITH_START_TIME_OBJ(startTime, pKvsPeerConnection->peerConnectionDiagnostics.freePeerConnectionTime, "Free peer connection");
SAFE_MEMFREE(*ppPeerConnection);
pKvsPeerConnection = NULL;
CleanUp:
if (pKvsPeerConnection != NULL) {
if (IS_VALID_MUTEX_VALUE(pKvsPeerConnection->twccLock)) {
if (IS_VALID_MUTEX_VALUE(pKvsPeerConnection->twccLock)) {
if (twccLocked) {
MUTEX_UNLOCK(pKvsPeerConnection->twccLock);
twccLocked = FALSE;
}
MUTEX_FREE(pKvsPeerConnection->twccLock);
}
pKvsPeerConnection->twccLock = INVALID_MUTEX_VALUE;
}

PROFILE_WITH_START_TIME_OBJ(startTime, pKvsPeerConnection->peerConnectionDiagnostics.freePeerConnectionTime, "Free peer connection");
SAFE_MEMFREE(*ppPeerConnection);

CleanUp:

LEAVES();
return retStatus;
}
Expand Down

0 comments on commit 8b37424

Please sign in to comment.