Skip to content

Commit

Permalink
Add logs to debug CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankiesz committed Nov 12, 2024
1 parent 9264d43 commit d7def8f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/source/Ice/ConnectionListener.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ STATUS freeConnectionListener(PConnectionListener* ppConnectionListener)
#ifndef _WIN32
socketWrite(pConnectionListener->kickSocket[CONNECTION_LISTENER_KICK_SOCKET_WRITE], msg, STRLEN(msg));
#endif

DLOGW("[TESTING] LOCKING pConnectionListener->lock for pConnectionListener->receiveDataRoutine.");
// receiveDataRoutine TID should be used under pConnectionListener->lock lock.
MUTEX_LOCK(pConnectionListener->lock);
threadId = pConnectionListener->receiveDataRoutine;
Expand All @@ -78,8 +80,10 @@ STATUS freeConnectionListener(PConnectionListener* ppConnectionListener)
}

MUTEX_UNLOCK(pConnectionListener->lock);
DLOGW("[TESTING] UNLOCKING pConnectionListener->lock for pConnectionListener->receiveDataRoutine.");
}

DLOGW("[TESTING] LOCKING pConnectionListener->lock for closeSocket.");
MUTEX_LOCK(pConnectionListener->lock);

// TODO add support for windows socketpair
Expand All @@ -93,6 +97,8 @@ STATUS freeConnectionListener(PConnectionListener* ppConnectionListener)
#endif

MUTEX_UNLOCK(pConnectionListener->lock);
DLOGW("[TESTING] UNLOCKING pConnectionListener->lock for closeSocket.");

MUTEX_FREE(pConnectionListener->lock);

MEMFREE(pConnectionListener);
Expand Down Expand Up @@ -336,10 +342,12 @@ PVOID connectionListenerReceiveDataRoutine(PVOID arg)
if (canReadFd(localSocket, rfds, nfds)) {
iterate = TRUE;
while (iterate) {
DLOGW("[TESTING] LOCKING pConnectionListener->lock for recvfrom.");
MUTEX_LOCK(pConnectionListener->lock);
readLen = recvfrom(localSocket, pConnectionListener->pBuffer, pConnectionListener->bufferLen, 0,
(struct sockaddr*) &srcAddrBuff, &srcAddrBuffLen);
MUTEX_UNLOCK(pConnectionListener->lock);
DLOGW("[TESTING] UNLOCKING pConnectionListener->lock for recvfrom.");

if (readLen < 0) {
switch (getErrorCode()) {
Expand Down
5 changes: 5 additions & 0 deletions src/source/Rtcp/RtpRollingBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ STATUS rtpRollingBufferAddRtpPacket(PRtpRollingBuffer pRollingBuffer, PRtpPacket
CHK_STATUS(rollingBufferAppendData(pRollingBuffer->pRollingBuffer, (UINT64) pRtpPacketCopy, &index));

CHK(pRollingBuffer->pRollingBuffer != NULL, STATUS_NULL_ARG);

DLOGW("[TESTING] LOCKING pRollingBuffer->lock for pRollingBuffer->lastIndex.");
MUTEX_LOCK(pRollingBuffer->pRollingBuffer->lock);
pRollingBuffer->lastIndex = index;
MUTEX_UNLOCK(pRollingBuffer->pRollingBuffer->lock);
DLOGW("[TESTING] UNLOCKING pRollingBuffer->lock for pRollingBuffer->lastIndex.");

CleanUp:
SAFE_MEMFREE(pRawPacketCopy);
Expand All @@ -98,6 +101,7 @@ STATUS rtpRollingBufferGetValidSeqIndexList(PRtpRollingBuffer pRollingBuffer, PU

CHK(pRollingBuffer != NULL && pRollingBuffer->pRollingBuffer && pValidSeqIndexList != NULL && pSequenceNumberList != NULL, STATUS_NULL_ARG);

DLOGW("[TESTING] LOCKING pRollingBuffer->lock for pRollingBuffer size.");
MUTEX_LOCK(pRollingBuffer->pRollingBuffer->lock);
rollingBufferLocked = TRUE;
CHK_STATUS(rollingBufferGetSize(pRollingBuffer->pRollingBuffer, &size));
Expand Down Expand Up @@ -133,6 +137,7 @@ STATUS rtpRollingBufferGetValidSeqIndexList(PRtpRollingBuffer pRollingBuffer, PU
CleanUp:
if (rollingBufferLocked) {
MUTEX_UNLOCK(pRollingBuffer->pRollingBuffer->lock);
DLOGW("[TESTING] UNLOCKING pRollingBuffer->lock for pRollingBuffer size.");
}

CHK_LOG_ERR(retStatus);
Expand Down
3 changes: 3 additions & 0 deletions src/source/Signaling/LwsApiCalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2417,12 +2417,15 @@ STATUS wakeLwsServiceEventLoop(PSignalingClient pSignalingClient, UINT32 protoco
// Early exit in case we don't need to do anything
CHK(pSignalingClient != NULL && pSignalingClient->pLwsContext != NULL, retStatus);

DLOGW("[TESTING] LOCKING pSignalingClient->lwsSerializerLock for pSignalingClient->currentWsi.");
// currentWsi should be used under lwsSerializerLock.
MUTEX_LOCK(pSignalingClient->lwsSerializerLock);
if (pSignalingClient->currentWsi[protocolIndex] != NULL) {
lws_callback_on_writable(pSignalingClient->currentWsi[protocolIndex]);
}
MUTEX_UNLOCK(pSignalingClient->lwsSerializerLock);
DLOGW("[TESTING] UNLOCKING pSignalingClient->lwsSerializerLock for pSignalingClient->currentWsi.");

CleanUp:

LEAVES();
Expand Down
2 changes: 2 additions & 0 deletions tst/IceFunctionalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ TEST_F(IceFunctionalityTest, connectionListenerFunctionalityTest)
EXPECT_EQ(connectionCount, newConnectionCount);

// receiveDataRoutine TID should be used under pConnectionListener->lock lock.
DLOGW("[TESTING] LOCKING pConnectionListener->lock for pConnectionListener->receiveDataRoutine.");
MUTEX_LOCK(pConnectionListener->lock);
threadId = pConnectionListener->receiveDataRoutine;
EXPECT_TRUE(IS_VALID_TID_VALUE(threadId));
Expand All @@ -207,6 +208,7 @@ TEST_F(IceFunctionalityTest, connectionListenerFunctionalityTest)
THREAD_JOIN(threadId, NULL);
pConnectionListener->receiveDataRoutine = INVALID_MUTEX_VALUE;
MUTEX_UNLOCK(pConnectionListener->lock);
DLOGW("[TESTING] UNLOCKING pConnectionListener->lock for pConnectionListener->receiveDataRoutine.");

EXPECT_EQ(STATUS_SUCCESS, freeConnectionListener(&pConnectionListener));

Expand Down

0 comments on commit d7def8f

Please sign in to comment.