Skip to content

Commit

Permalink
Move context initialize setting to top of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
disa6302 committed Sep 26, 2023
1 parent e089da4 commit 1092daf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,12 +1605,18 @@ STATUS initKvsWebRtc(VOID)
STATUS cleanupWebRtcClientInstance()
{
STATUS retStatus = STATUS_SUCCESS;

// Stun object cleanup
PWebRtcClientContext pWebRtcClientContext = getWebRtcClientInstance();

releaseHoldOnInstance(pWebRtcClientContext);

DLOGD("Releasing webrtc client context instance from cleanupWebRtcClientInstance");

CHK_WARN(ATOMIC_LOAD_BOOL(&pWebRtcClientContext->isContextInitialized), STATUS_INVALID_OPERATION,
"WebRtc context not initialized, nothing to clean up");
DLOGD("Releasing webrtc client context instance from cleanupWebRtcClientInstance");
releaseHoldOnInstance(pWebRtcClientContext);

ATOMIC_STORE_BOOL(&pWebRtcClientContext->isContextInitialized, FALSE);

while (ATOMIC_LOAD(&pWebRtcClientContext->contextRefCnt) > 0) {
DLOGV("Waiting on all references to be returned...%d", pWebRtcClientContext->contextRefCnt);
Expand All @@ -1633,8 +1639,6 @@ STATUS cleanupWebRtcClientInstance()
pWebRtcClientContext->stunCtxlock = INVALID_MUTEX_VALUE;
}

ATOMIC_STORE_BOOL(&pWebRtcClientContext->isContextInitialized, FALSE);

DLOGI("Destroyed WebRtc client context");

CleanUp:
Expand Down

0 comments on commit 1092daf

Please sign in to comment.