bug fix -> deadlock

This commit is contained in:
Volker Fischer 2008-08-17 21:06:25 +00:00
parent fb363895ab
commit 1e6f9f0dd9

View file

@ -164,20 +164,22 @@ void CProtocol::EnqueueMessage ( CVector<uint8_t>& vecMessage,
void CProtocol::SendMessage() void CProtocol::SendMessage()
{ {
QMutexLocker locker ( &Mutex );
CVector<uint8_t> vecMessage; CVector<uint8_t> vecMessage;
bool bSendMess = false; bool bSendMess = false;
// we have to check that list is not empty, since in another thread the Mutex.lock();
// last element of the list might have been erased
if ( !SendMessQueue.empty() )
{ {
vecMessage.Init ( SendMessQueue.front().vecMessage.Size() ); // we have to check that list is not empty, since in another thread the
vecMessage = SendMessQueue.front().vecMessage; // last element of the list might have been erased
if ( !SendMessQueue.empty() )
{
vecMessage.Init ( SendMessQueue.front().vecMessage.Size() );
vecMessage = SendMessQueue.front().vecMessage;
bSendMess = true; bSendMess = true;
}
} }
Mutex.unlock();
if ( bSendMess ) if ( bSendMess )
{ {