summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2009-09-01 16:17:25 -0700
committerDmitry Shmidt <dimitrysh@google.com>2009-09-01 16:20:07 -0700
commitd8f7ee5f20e2e0c651e6041c1d01c5beda4f4a99 (patch)
tree665c6df7da8b153aac64dc5a5ab793ee7d904553
parent6a0d0824f00909557486f113d52716238595aaa0 (diff)
downloadti-d8f7ee5f20e2e0c651e6041c1d01c5beda4f4a99.tar.gz
Fix race conditions during removing items from the queue
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r--wilink_6_1/stad/src/Ctrl_Interface/CmdHndlr.c14
-rw-r--r--wilink_6_1/stad/src/Data_link/txDataQueue.c15
-rw-r--r--wilink_6_1/stad/src/Data_link/txMgmtQueue.c15
-rw-r--r--wilink_6_1/utils/timer.c5
4 files changed, 31 insertions, 18 deletions
diff --git a/wilink_6_1/stad/src/Ctrl_Interface/CmdHndlr.c b/wilink_6_1/stad/src/Ctrl_Interface/CmdHndlr.c
index 0bf96c1..be737c6 100644
--- a/wilink_6_1/stad/src/Ctrl_Interface/CmdHndlr.c
+++ b/wilink_6_1/stad/src/Ctrl_Interface/CmdHndlr.c
@@ -156,11 +156,15 @@ void cmdHndlr_ClearQueue (TI_HANDLE hCmdHndlr)
TConfigCommand *pCurrCmd;
/* Dequeue and free all queued commands */
- while ( (pCurrCmd = (TConfigCommand *)que_Dequeue(pCmdHndlr->hCmdQueue)) != NULL )
- {
- /* Just release the semaphore. The command is freed subsequently. */
- os_SignalObjectSet (pCmdHndlr->hOs, pCurrCmd->pSignalObject);
- }
+ do {
+ context_EnterCriticalSection (pCmdHndlr->hContext);
+ pCurrCmd = (TConfigCommand *)que_Dequeue(pCmdHndlr->hCmdQueue);
+ context_LeaveCriticalSection (pCmdHndlr->hContext);
+ if (pCurrCmd != NULL) {
+ /* Just release the semaphore. The command is freed subsequently. */
+ os_SignalObjectSet (pCmdHndlr->hOs, pCurrCmd->pSignalObject);
+ }
+ } while (pCurrCmd != NULL);
}
diff --git a/wilink_6_1/stad/src/Data_link/txDataQueue.c b/wilink_6_1/stad/src/Data_link/txDataQueue.c
index 7c2a4a0..27d2ad2 100644
--- a/wilink_6_1/stad/src/Data_link/txDataQueue.c
+++ b/wilink_6_1/stad/src/Data_link/txDataQueue.c
@@ -222,8 +222,7 @@ TI_STATUS txDataQ_Destroy (TI_HANDLE hTxDataQ)
{
if (que_Destroy(pTxDataQ->aQueues[uQueId]) != TI_OK)
{
-TRACE1(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQueue_unLoad: fail to free Data Queue number: %d\n",uQueId);
-
+ TRACE1(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQueue_unLoad: fail to free Data Queue number: %d\n",uQueId);
status = TI_NOK;
}
}
@@ -255,10 +254,14 @@ void txDataQ_ClearQueues (TI_HANDLE hTxDataQ)
/* Dequeue and free all queued packets */
for (uQueId = 0 ; uQueId < pTxDataQ->uNumQueues ; uQueId++)
{
- while ( (pPktCtrlBlk = (TTxCtrlBlk *) que_Dequeue(pTxDataQ->aQueues[uQueId])) != NULL )
- {
- txCtrl_FreePacket (pTxDataQ->hTxCtrl, pPktCtrlBlk, TI_NOK);
- }
+ do {
+ context_EnterCriticalSection (pTxDataQ->hContext);
+ pPktCtrlBlk = (TTxCtrlBlk *) que_Dequeue(pTxDataQ->aQueues[uQueId]);
+ context_LeaveCriticalSection (pTxDataQ->hContext);
+ if (pPktCtrlBlk != NULL) {
+ txCtrl_FreePacket (pTxDataQ->hTxCtrl, pPktCtrlBlk, TI_NOK);
+ }
+ } while (pPktCtrlBlk != NULL);
}
}
diff --git a/wilink_6_1/stad/src/Data_link/txMgmtQueue.c b/wilink_6_1/stad/src/Data_link/txMgmtQueue.c
index 8bd8305..24253a5 100644
--- a/wilink_6_1/stad/src/Data_link/txMgmtQueue.c
+++ b/wilink_6_1/stad/src/Data_link/txMgmtQueue.c
@@ -276,8 +276,7 @@ TI_STATUS txMgmtQ_Destroy (TI_HANDLE hTxMgmtQ)
{
if (que_Destroy(pTxMgmtQ->aQueues[uQueId]) != TI_OK)
{
-TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "txMgmtQueue_unLoad: fail to free Mgmt Queue number: %d\n",uQueId);
-
+ TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "txMgmtQueue_unLoad: fail to free Mgmt Queue number: %d\n",uQueId);
eStatus = TI_NOK;
}
}
@@ -309,10 +308,14 @@ void txMgmtQ_ClearQueues (TI_HANDLE hTxMgmtQ)
/* Dequeue and free all queued packets */
for (uQueId = 0 ; uQueId < NUM_OF_MGMT_QUEUES ; uQueId++)
{
- while ( (pPktCtrlBlk = (TTxCtrlBlk *)que_Dequeue(pTxMgmtQ->aQueues[uQueId])) != NULL )
- {
- txCtrl_FreePacket (pTxMgmtQ->hTxCtrl, pPktCtrlBlk, TI_NOK);
- }
+ do {
+ context_EnterCriticalSection (pTxMgmtQ->hContext);
+ pPktCtrlBlk = (TTxCtrlBlk *)que_Dequeue(pTxMgmtQ->aQueues[uQueId]);
+ context_LeaveCriticalSection (pTxMgmtQ->hContext);
+ if (pPktCtrlBlk != NULL) {
+ txCtrl_FreePacket (pTxMgmtQ->hTxCtrl, pPktCtrlBlk, TI_NOK);
+ }
+ } while (pPktCtrlBlk != NULL);
}
}
diff --git a/wilink_6_1/utils/timer.c b/wilink_6_1/utils/timer.c
index f0718a1..d3d10cd 100644
--- a/wilink_6_1/utils/timer.c
+++ b/wilink_6_1/utils/timer.c
@@ -180,14 +180,18 @@ void tmr_ClearInitQueue (TI_HANDLE hTimerModule)
{
TTimerModule *pTimerModule = (TTimerModule *)hTimerModule;
+ context_EnterCriticalSection (pTimerModule->hContext);
while (que_Dequeue (pTimerModule->hInitQueue) != NULL) {}
+ context_LeaveCriticalSection (pTimerModule->hContext);
}
void tmr_ClearOperQueue (TI_HANDLE hTimerModule)
{
TTimerModule *pTimerModule = (TTimerModule *)hTimerModule;
+ context_EnterCriticalSection (pTimerModule->hContext);
while (que_Dequeue (pTimerModule->hOperQueue) != NULL) {}
+ context_LeaveCriticalSection (pTimerModule->hContext);
}
@@ -594,4 +598,3 @@ void tmr_PrintTimer (TI_HANDLE hTimerInfo)
#endif /* TI_DBG */
-