Browse Source

SRB ping-pong

AGP
Evgeny Gagua 1 year ago
parent
commit
86bcee9cdb
  1. 2
      Projects/la_serva/build
  2. 2
      lib/App/serva/servaRemoteClientHandler.cpp
  3. 10
      lib/App/serva/servaSessionManager.cpp
  4. 4
      lib/data/net/netClientHandler.cpp
  5. 8
      lib/data/net/netServer.cpp
  6. 26
      lib/data/transport/transportSocket.cpp

2
Projects/la_serva/build

@ -4,7 +4,7 @@
#make clean -e "CFG=Debug" #make clean -e "CFG=Debug"
#make -e "CFG=Debug" -j$(nproc) #make -e "CFG=Debug" -j$(nproc)
#make clean -e "CFG=Debug86"
make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j$(nproc) make -e "CFG=Debug86" -j$(nproc)
#make clean -e "CFG=Release86" #make clean -e "CFG=Release86"

2
lib/App/serva/servaRemoteClientHandler.cpp

@ -298,7 +298,7 @@ void servaRPCHadnler::m_fThreadProc( void ){
}; };
SLEEP(DEFAULT_THREAD_SLEEP_TIME); SLEEP(DEFAULT_THREAD_SLEEP_TIME);
}; };
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Connector Thread Ended!"); LOG("Connector Thread Ended!");
#endif #endif
}; };

10
lib/App/serva/servaSessionManager.cpp

@ -243,7 +243,7 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu
// At Time of Video Addition the Session May be expired already!! // At Time of Video Addition the Session May be expired already!!
// No neet to Validate session! // No neet to Validate session!
bool bExpiredSession = false;
SESSION_DATA *sp = validateSession( ptr->session_id ); SESSION_DATA *sp = validateSession( ptr->session_id );
if ( sp == NULL ) { if ( sp == NULL ) {
sp = reopenSession( ptr->session_id ); sp = reopenSession( ptr->session_id );
@ -251,6 +251,7 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu
LOG_ERROR( "Session Data ptr is null!"); LOG_ERROR( "Session Data ptr is null!");
return false; return false;
}; };
bExpiredSession = true;
}; };
if ( sp->m_pDataReport ) { if ( sp->m_pDataReport ) {
char tName[MAX_PATH]; char tName[MAX_PATH];
@ -258,7 +259,7 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu
chown( tName, getUserUid(web_access_user), getUserGid(web_access_group) ); chown( tName, getUserUid(web_access_user), getUserGid(web_access_group) );
chmod( tName, DB_FILE_MODE ); chmod( tName, DB_FILE_MODE );
updateSessionStat( ptr->session_id, false ); updateSessionStat( ptr->session_id, false );
char tQBuf[1024];
char tQBuf[CTEXT];
sprintf( tQBuf, "INSERT INTO `videos`(`session_id`,`module_id`,`uuid`,`ts`,`ts_ms`,`ext`,`fps`) VALUES(%" PRIu64 ", %d,'%s',%d,%d,'%s',%d)", sprintf( tQBuf, "INSERT INTO `videos`(`session_id`,`module_id`,`uuid`,`ts`,`ts_ms`,`ext`,`fps`) VALUES(%" PRIu64 ", %d,'%s',%d,%d,'%s',%d)",
ptr->session_id, ptr->session_id,
ptr->module_id, ptr->module_id,
@ -272,7 +273,10 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu
LOG( tQBuf ); LOG( tQBuf );
#endif #endif
bool rv = sp->m_pDataReport->SilentQuery( tQBuf ); bool rv = sp->m_pDataReport->SilentQuery( tQBuf );
if (sp->skeep_validation ) dropSession( ptr->session_id );
if( bExpiredSession ){
delete( sp->m_pDataReport );
free( sp );
};
return rv; return rv;
} else { } else {
LOG_ERROR( "Report DB is closed!"); LOG_ERROR( "Report DB is closed!");

4
lib/data/net/netClientHandler.cpp

@ -25,7 +25,7 @@ networkClientHandler::networkClientHandler( int SocketFD, networkServiceEngine *
}; };
networkClientHandler::~networkClientHandler(){ networkClientHandler::~networkClientHandler(){
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor Start"); LOG("Destructor Start");
# endif # endif
m_pEngine = NULL; m_pEngine = NULL;
@ -40,7 +40,7 @@ networkClientHandler::~networkClientHandler(){
# endif # endif
}; };
*/ */
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor Finished"); LOG("Destructor Finished");
# endif # endif
}; };

8
lib/data/net/netServer.cpp

@ -386,16 +386,16 @@ void networkServer::m_fThreadProc( void ){
//LRF_ClientHandler *tClient = (LRF_ClientHandler *)(*index); //LRF_ClientHandler *tClient = (LRF_ClientHandler *)(*index);
if( (*index)->getStatus() == false ){ if( (*index)->getStatus() == false ){
// Remove Client Handler // Remove Client Handler
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Remove Client"); LOG("Remove Client");
#endif #endif
if( m_pKernelEngine ){ if( m_pKernelEngine ){
if ( m_pKernelEngine->detachClient( (*index) ) ){ if ( m_pKernelEngine->detachClient( (*index) ) ){
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Client Stoped"); LOG("Client Stoped");
#endif #endif
m_vHandlersPool.erase( index ); m_vHandlersPool.erase( index );
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Remove Client Done"); LOG("Remove Client Done");
#endif #endif
} else LOG_ERROR("Client detach from Kernel Failure!"); } else LOG_ERROR("Client detach from Kernel Failure!");
@ -447,12 +447,12 @@ void networkServer::m_fThreadProc( void ){
flags |= O_NONBLOCK | O_NDELAY; flags |= O_NONBLOCK | O_NDELAY;
//RetCode = ioctl( MainSocket, FIONBIO, (char *) &dontblock ); //RetCode = ioctl( MainSocket, FIONBIO, (char *) &dontblock );
RetCode = fcntl( ClientSocket, F_SETFL, flags ); RetCode = fcntl( ClientSocket, F_SETFL, flags );
#ifdef DEBUG_EXTRA
if ( RetCode == 0 ){ if ( RetCode == 0 ){
LOG( "Set N-Blocking Mode of Client Socket" ); LOG( "Set N-Blocking Mode of Client Socket" );
} else { } else {
LOG( "Can't set N-Blocking Mode of Client Socket" ); LOG( "Can't set N-Blocking Mode of Client Socket" );
}; };
#ifdef DEBUG
LOG( "Client Connection Accepted" ); LOG( "Client Connection Accepted" );
#endif #endif
if( m_pKernelEngine ) { if( m_pKernelEngine ) {

26
lib/data/transport/transportSocket.cpp

@ -38,12 +38,12 @@ transportSocket::transportSocket() : basicTransport(), basicDualThread(){
// Destructor implementation // Destructor implementation
transportSocket::~transportSocket(){ transportSocket::~transportSocket(){
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor begin!"); LOG("Destructor begin!");
# endif # endif
m_mBufferProtectorMutex.unlock(); m_mBufferProtectorMutex.unlock();
_close(); _close();
# ifdef DEBUG
# ifdef DEBUG_EXTRA
LOG("Destructor end!"); LOG("Destructor end!");
# endif # endif
}; };
@ -57,23 +57,23 @@ bool transportSocket::create( void ){
bool transportSocket::_close( void ){ bool transportSocket::_close( void ){
setConnectionStatus( CS_DISCONNECTED ); setConnectionStatus( CS_DISCONNECTED );
LOG("Sending Close Req!");
//LOG("Sending Close Req!");
if( m_iControlPipeFD[0] > -1 ){ if( m_iControlPipeFD[0] > -1 ){
LOG("Sending Close Req[1]!");
//LOG("Sending Close Req[1]!");
write( m_iControlPipeFD[0], "E", 1 ); write( m_iControlPipeFD[0], "E", 1 );
}; };
if( m_iControlPipeFD[1] > -1 ){ if( m_iControlPipeFD[1] > -1 ){
LOG("Sending Close Req[2]!");
//LOG("Sending Close Req[2]!");
write( m_iControlPipeFD[1], "E", 1 ); write( m_iControlPipeFD[1], "E", 1 );
}; };
if( m_bInitComplete ) m_bInitComplete = !uninit(); if( m_bInitComplete ) m_bInitComplete = !uninit();
LOG("Closeing FIDs!");
//LOG("Closeing FIDs!");
if ( m_iControlPipeFD[0] > -1 ){ if ( m_iControlPipeFD[0] > -1 ){
LOG("Closeing FIDs[1]!");
//LOG("Closeing FIDs[1]!");
close( m_iControlPipeFD[0] ); close( m_iControlPipeFD[0] );
}; };
if ( m_iControlPipeFD[1] > -1 ){ if ( m_iControlPipeFD[1] > -1 ){
LOG("Closeing FIDs[2]!");
//LOG("Closeing FIDs[2]!");
close( m_iControlPipeFD[1] ); close( m_iControlPipeFD[1] );
}; };
return true; return true;
@ -132,14 +132,14 @@ void transportSocket::m_fThreadAProc(void){
if ( buffer == 'E' ) { if ( buffer == 'E' ) {
//m_bThreadBStatus = TH_ENDED; //m_bThreadBStatus = TH_ENDED;
m_bThreadAStatus = TH_ENDED; m_bThreadAStatus = TH_ENDED;
LOG("Requesting Destruction of Transport[s]!");
//LOG("Requesting Destruction of Transport[s]!");
}; };
}; };
}; };
}; };
}; };
}; };
LOG("Sender Thread End!");
//LOG("Sender Thread End!");
}; };
void transportSocket::m_fThreadBProc(void){ void transportSocket::m_fThreadBProc(void){
@ -177,8 +177,10 @@ void transportSocket::m_fThreadBProc(void){
setConnectionStatus(CS_DISCONNECTED); setConnectionStatus(CS_DISCONNECTED);
m_nInputBufferSize = 0; m_nInputBufferSize = 0;
m_bThreadBStatus = TH_ENDED; m_bThreadBStatus = TH_ENDED;
//m_bThreadAStatus = TH_ENDED;
//m_bThreadAStatus = TH_ENDED;
#ifdef DEBUG_EXTRA
LOG_ERROR("Connection Droped on Reception Data"); LOG_ERROR("Connection Droped on Reception Data");
#endif
} else if( m_nInputBufferSize > 0 ){ } else if( m_nInputBufferSize > 0 ){
do{ do{
m_mQueueProtectorMutex.lock(); m_mQueueProtectorMutex.lock();
@ -203,7 +205,9 @@ void transportSocket::m_fThreadBProc(void){
}; };
}; };
}; };
#ifdef DEBUG_EXTRA
LOG("Recipient Thread End!"); LOG("Recipient Thread End!");
#endif
}; };
bool transportSocket::sendData(unsigned char *Data, int DataSize){ bool transportSocket::sendData(unsigned char *Data, int DataSize){

Loading…
Cancel
Save