do not start server and any protocol message but only on audio packet (to avoid server is restarted on disconnect message)

This commit is contained in:
Volker Fischer 2009-10-11 09:50:58 +00:00
parent 5df18595d2
commit 10faecd5cc
5 changed files with 46 additions and 7 deletions

View file

@ -356,6 +356,21 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
bIsProtocolPacket = true; bIsProtocolPacket = true;
} }
} }
else
{
// In case we are the server and the current channel is not
// connected, we do not evaluate protocal messages but these
// messages could start the server which is not desired, especially
// not for the disconnect messages.
// We now do not start the server if a valid protocol message
// was received but only start the server on audio packets
if ( Protocol.IsProtocolMessage ( vecbyData, iNumBytes ) )
{
// set status flags
eRet = PS_PROT_OK_MESS_NOT_EVALUATED;
bIsProtocolPacket = true;
}
}
// only try to parse audio if it was not a protocol packet // only try to parse audio if it was not a protocol packet
if ( !bIsProtocolPacket ) if ( !bIsProtocolPacket )
@ -421,6 +436,12 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
// (this is only required for server since we defined that the // (this is only required for server since we defined that the
// server has to send with the same properties as sent by // server has to send with the same properties as sent by
// the client) // the client)
// TODO check the conditions: !bIsProtocolPacket should always be true
// since we can only get here if bNewConnection, should we really put
// !bIsAudioPacket in here, because shouldn't we always quere the audio
// properties on a new connection?
if ( bIsServer && ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) ) if ( bIsServer && ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) )
{ {
Protocol.CreateReqNetwTranspPropsMes(); Protocol.CreateReqNetwTranspPropsMes();

View file

@ -47,6 +47,7 @@ enum EPutDataStat
PS_AUDIO_OK, PS_AUDIO_OK,
PS_AUDIO_ERR, PS_AUDIO_ERR,
PS_PROT_OK, PS_PROT_OK,
PS_PROT_OK_MESS_NOT_EVALUATED,
PS_PROT_ERR PS_PROT_ERR
}; };

View file

@ -287,6 +287,18 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID,
emit MessReadyForSending ( vecAcknMessage ); emit MessReadyForSending ( vecAcknMessage );
} }
bool CProtocol::IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes )
{
/*
just check if this is a protocol message but do not act on message
*/
int iRecCounter, iRecID;
CVector<uint8_t> vecData;
return !ParseMessageFrame ( vecbyData, iNumBytes, iRecCounter, iRecID, vecData );
}
bool CProtocol::ParseMessage ( const CVector<uint8_t>& vecbyData, bool CProtocol::ParseMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes ) const int iNumBytes )
{ {
@ -973,9 +985,6 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
int& iID, int& iID,
CVector<uint8_t>& vecData ) CVector<uint8_t>& vecData )
{ {
/*
return code: true -> ok; false -> error
*/
int iLenBy, i; int iLenBy, i;
unsigned int iCurPos; unsigned int iCurPos;

View file

@ -88,7 +88,10 @@ public:
void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt ); void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt );
bool ParseMessage ( const CVector<uint8_t>& vecbyData, bool ParseMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes ); const int iNumBytes );
bool IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes );
protected: protected:
class CSendMessage class CSendMessage

View file

@ -621,8 +621,9 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
const int iNumBytesRead, const int iNumBytesRead,
const CHostAddress& HostAdr ) const CHostAddress& HostAdr )
{ {
bool bChanOK = true; // init with ok, might be overwritten bool bChanOK = true; // init with ok, might be overwritten
bool bNewChannelReserved = false; bool bNewChannelReserved = false;
bool bIsNotEvaluatedProtocolMessage = false;
Mutex.lock(); Mutex.lock();
{ {
@ -688,11 +689,15 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
case PS_PROT_ERR: case PS_PROT_ERR:
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID ); PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID );
break; break;
case PS_PROT_OK_MESS_NOT_EVALUATED:
bIsNotEvaluatedProtocolMessage = true; // set flag
break;
} }
} }
// act on new channel connection // act on new channel connection
if ( bNewChannelReserved ) if ( bNewChannelReserved && ( !bIsNotEvaluatedProtocolMessage ) )
{ {
// logging of new connected channel // logging of new connected channel
Logging.AddNewConnection ( HostAdr.InetAddr ); Logging.AddNewConnection ( HostAdr.InetAddr );