int CTCPServerConnectionMonitor::_Process_CreateListenSocket()
{
	int nFunRes = 0;
	try
	{
		DEF_DELETE(m_pTCPServerSocket);
		m_pTCPServerSocket = new  TcpServerSocket<TcpSocket>(BIND_TO_ALL_INTERFACES, m_strListenSocketPort);	
		m_pTCPServerSocket->bind();
		m_pTCPServerSocket->listen(); 
		_LOG(SourceFLInfo, DebugDebug, "server port = %s listening", m_strListenSocketPort.c_str());
		
		m_SetTCPServerSocket.addSocket(m_pTCPServerSocket);
		nFunRes = 0;
	}
	catch (...)
	{
		_LOG(SourceFLInfo, DebugError, "bind server port = %s error!", m_strListenSocketPort.c_str());

		DEF_DELETE(m_pTCPServerSocket);
		nFunRes = -1;
		return nFunRes;
	}
	
	return nFunRes;
}
Exemplo n.º 2
0
CAIElectLord::~CAIElectLord(void)
{
	_CleanEnv();
	DEF_DELETE(m_pCommonLogic);
	DEF_DELETE(m_pCardsHelper);
	m_pTestCards = NULL;
}
Exemplo n.º 3
0
/*
----------
  open
  Открытие файла
----------
*/
HRESULT File::Open(const char *file_name, BYTE file_mode, BYTE warnLevel/* = Filelevel_all*/)
{
  if(this->_file)
    this->Close();
  int len = int(strlen(file_name));
  DEF_DELETE(this->_name);
  std::string path, oldDir = tools::GetCurDirectory(), fileName = tools::GetFileNameFromPath(file_name);
  if((path = tools::GetPathFromFilePath(file_name)).length())  //need to change directory
  {
    tools::SetCurDirectory(tools::GetCorePath());
    if(path.length() && this->_mode != File_mode_READ)
      CreateDirectory(path.data(), 0);
    tools::SetCurDirectory(path);
  }
  //__log.PrintInfo(Filelevel_DEBUG, "=> [%s][%s]", path.data(), getCurrentDirectory().data());
  this->_name = new char[len + 1];
  memcpy(this->_name, file_name, len + 1);
  this->_mode = file_mode;
  char m[4];
  switch(this->_mode)
  {
  case File_mode_WRITE:
    m[0] = 'w';
    m[1] = 'b';
    m[2] = '+';
    m[3] = 0;
  break;
  case File_mode_READ:
    m[0] = 'r';
    m[1] = 'b';
    m[2] = 0;
  break;
  case File_mode_APPEND:
    m[0] = 'a';
    m[1] = 'b';
    m[2] = 0;
  break;
  case File_mode_EDIT:
    m[ 0 ] = 'r';
    m[ 1 ] = 'b';
    m[ 2 ] = '+';
    m[ 3 ] = 0;
  break;
  }
  fopen_s(&this->_file, fileName.data(), m);
  __log.PrintInfo(Filelevel_DEBUG, "File::Open('%s') open in directory %s", fileName.data(), tools::GetCurDirectory().data());
  if(path.length())
    tools::SetCurDirectory(oldDir);
  if(this->_file == 0)
  {
    __log.PrintInfo(Filelevel_WARNING, "File::Open('%s', '%s')  -  can't open file", this->_name, m);
    return -1;
  }
  this->_length = tools::FileSize(this->_file);
  this->_logLevel = warnLevel;
  this->_cur_pos = 0;

  return 0;
}//open
Exemplo n.º 4
0
CGenerateSQLFile::~CGenerateSQLFile()
{
	_ClossAllOutPutFiles();
	DEF_DELETE(m_pSQLCodeInfo);	
	m_vrtDataInFile.clear(); 	
	CLogger::removeInstance();
	CUtilityFun::removeInstance();
	CSQLDataProcessor::removeInstance();
}
int CTCPServerConnectionMonitor::_ProcessUserTerminate()
{
	int nFunRes = 0;
	//user termin
	m_nThreadJobState = Job_State_End;
	
	if (NULL != m_pTCPServerRequestMonitor)
	{
		m_pTCPServerRequestMonitor->terminateAndWait();
		DEF_DELETE(m_pTCPServerRequestMonitor);
	}

	if (NULL != m_pTCPServerSocket)
	{
		m_SetTCPServerSocket.removeSocket(m_pTCPServerSocket);
		DEF_DELETE(m_pTCPServerSocket);		
	}
	   	
	return nFunRes;
}
Exemplo n.º 6
0
void CServerManager::removeInstance()
{
	BOOST_LOG_FUNCTION();	

	boost::mutex::scoped_lock lock(m_instanceLock);

	if (NULL != m_pInstance)
	{
		DEF_DELETE(m_pInstance);
	}

}
Exemplo n.º 7
0
RenderableQuad::~RenderableQuad()
{
  //TODO: because RenderableQuad inherited from ISprite, info deleted at ~ISprite
  /*
  if( this->info->indexInRenderableList != RENDERABLE_INDEX_UNDEFINED ) {
    this->info->DestroyExternalRenderableInListFunc( NULL, NULL, NULL, this->info->indexInRenderableList );
  } else {
  */
    //DEF_DELETE( this->info->animation );
    //delete this->info;
  //}
  DEF_DELETE( this->info );
}//destructor
Exemplo n.º 8
0
void CTableInfo::_FreeData()
{		
	std::list<CSQLType*>::iterator itemLst;
	CSQLType* pGet = NULL;

	itemLst = m_LstDBInfo.begin();
	while (itemLst != m_LstDBInfo.end())
	{
		pGet = (*itemLst);
		DEF_DELETE(pGet);
		itemLst++;
	}
	m_strTableName.clear();
	m_LstDBInfo.clear();
} 
Exemplo n.º 9
0
void CPokerCardList::clearAllData()
{
	int nFunRes = 0;
	CPokerCard* pPokderCardGet = NULL;
	std::list<CPokerCard*>::iterator  iterList;

	iterList = m_pPokerCardList->begin();
	while (iterList != m_pPokerCardList->end())
	{
		pPokderCardGet = *iterList;
		DEF_DELETE(pPokderCardGet);
		iterList++;
	}//while
	m_pPokerCardList->clear();
}
int CTCPServerConnectionMonitor::_AcceptClient(TcpServerSocket<TcpSocket>* pTCPServerSocket)
{
	int nFunRes = 0;
	TcpSocket*	pNewClientSocket = NULL;
	CTCPConnectionActor* pActor = NULL;

	try
	{
		pNewClientSocket = pTCPServerSocket->accept(SERVER_NON_BLOCKING_ACCEPT, false); //SERVER_BLOCKING_ACCEPT
		nFunRes = 0;		
	}
	catch(...)
	{
		_LOG(SourceFLInfo, DebugError, "ServerSocket accept new Tcp Client error");
		DEF_DELETE(pNewClientSocket);
		nFunRes = -1;
		return nFunRes;
	}


	try
	{
		pActor = new CTCPConnectionActor(pNewClientSocket);
		pNewClientSocket = NULL;

	}
	catch (...)
	{
		DEF_DELETE(pActor);
	}

	m_pTCPServerRequestMonitor->addSocket(pActor);
	

	return nFunRes;
}
Exemplo n.º 11
0
/*
----------
  Destructor
----------
*/
File::~File()
{
  this->Close();
  if(this->_name)
    DEF_DELETE(this->_name);
}//destructor
Exemplo n.º 12
0
CCommonLogic::~CCommonLogic(void)
{
	DEF_DELETE(m_pCardsHelper);
}
Exemplo n.º 13
0
CPokerCardList::~CPokerCardList(void)
{
	m_pPokerCardList->clear();
	DEF_DELETE(m_pPokerCardList);
}