Skip to content

Commit

Permalink
fix a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanctech committed Sep 22, 2021
1 parent 1fc4831 commit 0939024
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 0 additions & 5 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,6 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
locked = TRUE;
}
// Cancel the media thread
if(!(pSampleConfiguration->mediaThreadStarted)) {
DLOGD("Canceling media thread");
THREAD_CANCEL(pSampleConfiguration->mediaSenderTid);
}

for (i = 0; i < pSampleConfiguration->streamingSessionCount; ++i) {
retStatus = gatherIceServerStats(pSampleConfiguration->sampleStreamingSessionList[i]);
Expand Down
14 changes: 14 additions & 0 deletions samples/kvsWebRTCClientMaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ INT32 main(INT32 argc, CHAR* argv[])
// Kick of the termination sequence
ATOMIC_STORE_BOOL(&pSampleConfiguration->appTerminateFlag, TRUE);

if (IS_VALID_MUTEX_VALUE(pSampleConfiguration->sampleConfigurationObjLock)) {
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
}

// Cancel the media thread
if (pSampleConfiguration->mediaThreadStarted) {
DLOGD("Canceling media thread");
THREAD_CANCEL(pSampleConfiguration->mediaSenderTid);
}

if (IS_VALID_MUTEX_VALUE(pSampleConfiguration->sampleConfigurationObjLock)) {
MUTEX_UNLOCK(pSampleConfiguration->sampleConfigurationObjLock);
}

if (pSampleConfiguration->mediaSenderTid != INVALID_TID_VALUE) {
THREAD_JOIN(pSampleConfiguration->mediaSenderTid, NULL);
}
Expand Down
5 changes: 4 additions & 1 deletion src/source/Ice/ConnectionListener.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ PVOID connectionListenerReceiveDataRoutine(PVOID arg)

CleanUp:

if (pConnectionListener != NULL) {
// The check for valid mutex is necessary because when we're in freeConnectionListener
// we may free the mutex in another thread so by the time we get here accessing the lock
// will result in accessing a resource after it has been freed
if (pConnectionListener != NULL && IS_VALID_MUTEX_VALUE(pConnectionListener->lock)) {
// As TID is 64 bit we can't atomically update it and need to do it under the lock
MUTEX_LOCK(pConnectionListener->lock);
pConnectionListener->receiveDataRoutine = INVALID_TID_VALUE;
Expand Down

0 comments on commit 0939024

Please sign in to comment.