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)
|
- 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)
|
- 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,
|
void CServer::OnNewConnection ( int iChID,
|
||||||
CHostAddress RecHostAddr )
|
CHostAddress RecHostAddr )
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
// inform the client about its own ID at the server (note that this
|
// 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)
|
// must be the first message to be sent for a new connection)
|
||||||
vecChannels[iChID].CreateClientIDMes ( iChID );
|
vecChannels[iChID].CreateClientIDMes ( iChID );
|
||||||
|
@ -669,6 +671,8 @@ void CServer::OnNewConnection ( int iChID,
|
||||||
|
|
||||||
void CServer::OnServerFull ( CHostAddress RecHostAddr )
|
void CServer::OnServerFull ( CHostAddress RecHostAddr )
|
||||||
{
|
{
|
||||||
|
// note: no mutex required here
|
||||||
|
|
||||||
// inform the calling client that no channel is free
|
// inform the calling client that no channel is free
|
||||||
ConnLessProtocol.CreateCLServerFullMes ( RecHostAddr );
|
ConnLessProtocol.CreateCLServerFullMes ( RecHostAddr );
|
||||||
}
|
}
|
||||||
|
@ -681,16 +685,6 @@ void CServer::OnSendCLProtMessage ( CHostAddress InetAddr,
|
||||||
Socket.SendPacket ( vecMessage, 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 )
|
void CServer::OnCLDisconnection ( CHostAddress InetAddr )
|
||||||
{
|
{
|
||||||
// check if the given address is actually a client which is connected to
|
// check if the given address is actually a client which is connected to
|
||||||
|
@ -743,7 +737,6 @@ void CServer::OnHandledSignal ( int sigNum )
|
||||||
#else
|
#else
|
||||||
switch ( sigNum )
|
switch ( sigNum )
|
||||||
{
|
{
|
||||||
|
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
RequestNewRecording();
|
RequestNewRecording();
|
||||||
break;
|
break;
|
||||||
|
@ -1442,13 +1435,25 @@ int CServer::FindChannel ( const CHostAddress& CheckAddr )
|
||||||
return INVALID_CHANNEL_ID;
|
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,
|
void CServer::OnProtcolMessageReceived ( int iRecCounter,
|
||||||
int iRecID,
|
int iRecID,
|
||||||
CVector<uint8_t> vecbyMesBodyData,
|
CVector<uint8_t> vecbyMesBodyData,
|
||||||
CHostAddress RecHostAddr )
|
CHostAddress RecHostAddr )
|
||||||
{
|
{
|
||||||
Mutex.lock();
|
QMutexLocker locker ( &Mutex );
|
||||||
{
|
|
||||||
// find the channel with the received address
|
// find the channel with the received address
|
||||||
const int iCurChanID = FindChannel ( RecHostAddr );
|
const int iCurChanID = FindChannel ( RecHostAddr );
|
||||||
|
|
||||||
|
@ -1461,19 +1466,17 @@ void CServer::OnProtcolMessageReceived ( int iRecCounter,
|
||||||
RecHostAddr );
|
RecHostAddr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||||
const int iNumBytesRead,
|
const int iNumBytesRead,
|
||||||
const CHostAddress& HostAdr,
|
const CHostAddress& HostAdr,
|
||||||
int& iCurChanID )
|
int& iCurChanID )
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
bool bNewConnection = false; // init return value
|
bool bNewConnection = false; // init return value
|
||||||
bool bChanOK = true; // init with ok, might be overwritten
|
bool bChanOK = true; // init with ok, might be overwritten
|
||||||
|
|
||||||
Mutex.lock();
|
|
||||||
{
|
|
||||||
// Get channel ID ------------------------------------------------------
|
// Get channel ID ------------------------------------------------------
|
||||||
// check address
|
// check address
|
||||||
iCurChanID = FindChannel ( HostAdr );
|
iCurChanID = FindChannel ( HostAdr );
|
||||||
|
@ -1523,8 +1526,6 @@ bool CServer::PutAudioData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||||
bNewConnection = true;
|
bNewConnection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Mutex.unlock();
|
|
||||||
|
|
||||||
// return the state if a new connection was happening
|
// return the state if a new connection was happening
|
||||||
return bNewConnection;
|
return bNewConnection;
|
||||||
|
|
|
@ -458,10 +458,8 @@ public slots:
|
||||||
void OnCLReqVersionAndOS ( CHostAddress InetAddr )
|
void OnCLReqVersionAndOS ( CHostAddress InetAddr )
|
||||||
{ ConnLessProtocol.CreateCLVersionAndOSMes ( 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 )
|
void OnCLReqConnClientsList ( CHostAddress InetAddr )
|
||||||
{ QMutexLocker locker ( &Mutex ); ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); }
|
{ ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); }
|
||||||
|
|
||||||
void OnCLRegisterServerReceived ( CHostAddress InetAddr,
|
void OnCLRegisterServerReceived ( CHostAddress InetAddr,
|
||||||
CHostAddress LInetAddr,
|
CHostAddress LInetAddr,
|
||||||
|
|
Loading…
Reference in a new issue