while ( !m_fCheckTransferThreadClosing ) {
WaitForSingleObject( m_hCheckForDoneTransfersEvent, INFINITE );
if ( m_fCheckTransferThreadClosing ) {
break;
}
// Must be set when this thread is signalled but under stress conditions
// it could get temporarily unset by the time we get here. If that
// happens then we just wait for the event to get signalled again.
TDLINK pTD;
pTD.td = (P_TD) InterlockedExchange((LPLONG)&m_pDoneHead, 0L);
while (pTD.td) {
CPipe * pTDPipe;
if (pTD.td->bfIsIsoch) {
pTDPipe = pTD.itd->pPipe;
ASSERT(pTD.itd->pTransfer->GetPipe() == pTDPipe);
}
else {
pTDPipe = pTD.td->pPipe ;
ASSERT( pTD.td->pTransfer->GetPipe() == pTDPipe);
}
// these fields all have the same offsets for TDs and ITDs
if (pTD.td->bfDiscard) {
// the transfer has been aborted already and completed elsewhere
DEBUGMSG(ZONE_WARNING, (TEXT("CPipe::CFDT DISCARDING td %08x nxt %08x xfr %08x\n"), pTD.td, pTD.td->paNextTd.td,pTDPipe));
pTD = pTD.td->paNextTd;
continue;
}
DEBUGMSG(ZONE_TRANSFER && ZONE_VERBOSE, (TEXT("CPipe::CFDT td %08x nxt %08x xfr %08x\n"), pTD.td, pTD.td->paNextTd,pTDPipe));
// advance pTD first because it will get freed if it's the last TD of the transfer
// see notes above for why we can and want to advance multiple
TDLINK pNextTD = pTD.td->paNextTd; // same offset as for itd
RETAILMSG(N,(TEXT("TO CheckForDoneTransfers\r\n")));
pTDPipe->CheckForDoneTransfers(pTD);
pTD = pNextTD;
}
}
DEBUGMSG( ZONE_TRANSFER && ZONE_VERBOSE, (TEXT("-CHCCAera::CheckForDoneTransfersThread\n")) );
return 0;
}
无法再进入这个while (pTD.td)循环,而且也等不到hCheckForDoneTransfersEvent这个事件。不知道出现这样的问题,该有什么好的方法解决,多谢大家指教!!