added more mutex in the server (may fix #480)
This commit is contained in:
parent
e5174ef461
commit
df0ec35d05
3 changed files with 70 additions and 69 deletions
|
@ -15,6 +15,8 @@
|
|||
|
||||
- support MIDI control faders in headless build (#483)
|
||||
|
||||
- added more mutex in the server (may fix #480)
|
||||
|
||||
- bug fix: --showallservers ping column sort is alphabetic (#201)
|
||||
|
||||
|
||||
|
|
|
@ -599,6 +599,8 @@ void CServer::SendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
|||
void CServer::OnNewConnection ( int iChID,
|
||||
CHostAddress RecHostAddr )
|
||||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// inform the client about its own ID at the server (note that this
|
||||
// must be the first message to be sent for a new connection)
|
||||
vecChannels[iChID].CreateClientIDMes ( iChID );
|
||||
|
@ -669,6 +671,8 @@ void CServer::OnNewConnection ( int iChID,
|
|||
|
||||
void CServer::OnServerFull ( CHostAddress RecHostAddr )
|
||||
{
|
||||
// note: no mutex required here
|
||||
|
||||
// inform the calling client that no channel is free
|
||||
ConnLessProtocol.CreateCLServerFullMes ( RecHostAddr );
|
||||
}
|
||||
|
@ -681,16 +685,6 @@ void CServer::OnSendCLProtMessage ( CHostAddress InetAddr,
|
|||
Socket.SendPacket ( vecMessage, InetAddr );
|
||||
}
|
||||
|
||||
void CServer::OnProtcolCLMessageReceived ( int iRecID,
|
||||
CVector<uint8_t> vecbyMesBodyData,
|
||||
CHostAddress RecHostAddr )
|
||||
{
|
||||
// connection less messages are always processed
|
||||
ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData,
|
||||
iRecID,
|
||||
RecHostAddr );
|
||||
}
|
||||
|
||||
void CServer::OnCLDisconnection ( CHostAddress InetAddr )
|
||||
{
|
||||
// check if the given address is actually a client which is connected to
|
||||
|
@ -743,7 +737,6 @@ void CServer::OnHandledSignal ( int sigNum )
|
|||
#else
|
||||
switch ( sigNum )
|
||||
{
|
||||
|
||||
case SIGUSR1:
|
||||
RequestNewRecording();
|
||||
break;
|
||||
|
@ -1442,13 +1435,25 @@ int CServer::FindChannel ( const CHostAddress& CheckAddr )
|
|||
return INVALID_CHANNEL_ID;
|
||||
}
|
||||
|
||||
void CServer::OnProtcolCLMessageReceived ( int iRecID,
|
||||
CVector<uint8_t> vecbyMesBodyData,
|
||||
CHostAddress RecHostAddr )
|
||||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// connection less messages are always processed
|
||||
ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData,
|
||||
iRecID,
|
||||
RecHostAddr );
|
||||
}
|
||||
|
||||
void CServer::OnProtcolMessageReceived ( int iRecCounter,
|
||||
int iRecID,
|
||||
CVector<uint8_t> vecbyMesBodyData,
|
||||
CHostAddress RecHostAddr )
|
||||
{
|
||||
Mutex.lock();
|
||||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// find the channel with the received address
|
||||
const int iCurChanID = FindChannel ( RecHostAddr );
|
||||
|
||||
|
@ -1460,8 +1465,6 @@ void CServer::OnProtcolMessageReceived ( int iRecCounter,
|
|||
vecbyMesBodyData,
|
||||
RecHostAddr );
|
||||
}
|
||||
}
|
||||
Mutex.unlock();
|
||||
}
|
||||
|
||||
bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||
|
@ -1469,11 +1472,11 @@ bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
|||
const CHostAddress& HostAdr,
|
||||
int& iCurChanID )
|
||||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
bool bNewConnection = false; // init return value
|
||||
bool bChanOK = true; // init with ok, might be overwritten
|
||||
|
||||
Mutex.lock();
|
||||
{
|
||||
// Get channel ID ------------------------------------------------------
|
||||
// check address
|
||||
iCurChanID = FindChannel ( HostAdr );
|
||||
|
@ -1523,8 +1526,6 @@ bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
|||
bNewConnection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Mutex.unlock();
|
||||
|
||||
// return the state if a new connection was happening
|
||||
return bNewConnection;
|
||||
|
|
|
@ -458,10 +458,8 @@ public slots:
|
|||
void OnCLReqVersionAndOS ( CHostAddress InetAddr )
|
||||
{ ConnLessProtocol.CreateCLVersionAndOSMes ( InetAddr ); }
|
||||
|
||||
// the CreateChannelList() function access vecChannels which as to be mutexed
|
||||
// since the normal server thread my change that at a random time
|
||||
void OnCLReqConnClientsList ( CHostAddress InetAddr )
|
||||
{ QMutexLocker locker ( &Mutex ); ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); }
|
||||
{ ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); }
|
||||
|
||||
void OnCLRegisterServerReceived ( CHostAddress InetAddr,
|
||||
CHostAddress LInetAddr,
|
||||
|
|
Loading…
Reference in a new issue