Exemple #1
0
CBufferObj* CBufMgr::PopBuffer()
{
    CBufferObj* pBufObj;

    m_MutexRelloc.Lock();
    pBufObj = m_pBufferArray[m_iReadPos];
    if(NULL == pBufObj)
    {
        LOG2_INFO("Cur %d is NULL.\n", m_iReadPos );
        m_MutexRelloc.Unlock();
        return NULL;
    }
    m_pBufferArray[m_iReadPos] = NULL;
    m_iReadPos++;
    if(m_iReadPos >= m_iBufferArraySize)
    {
        m_iReadPos = 0;
    }
    m_MutexRelloc.Unlock();
    return pBufObj;
}
static void _rmUnusedEntries(s_sslSessCache_t *ps_sessCache)
{
    int i = 0;

    s_sslSessCache_t *pCache;

    assert(ps_sessCache != NULL);

    pCache = ps_sessCache;

    for (i = 0; i < NUM_CACHE_DB_ENTRIES; i++)
    {
        /* Check if this is an unused entry */
        if (pCache[i].i_lruCounter == FREE_CACHE_ENTRY)
        {
            /* reset the timer before it will been overwritten */
            tot2_resetTmr(&pCache[i].s_sessTimeout);
            /* Clear the entire cache entry */
            memset(&pCache[i], 0x00, sizeof(s_sslSessCache_t));
            LOG2_INFO("Session Cache Element @ %p has been erased", &pCache[i]);
        }
    }
}
Exemple #3
0
INT32 CNetChannel::ConnectServer(char* pszRemoteIPAddr, UINT16 uiRemotePort,
							char* pszBindingIPAddr, UINT16 uiBindingPort)
{
   
	INT32 iRet;
	enumNetProtocolType euPType;

    LOG2_INFO("ChnType(%d) Connect %s:%d bind:%s:%d", 
        GetChnType(),
        pszRemoteIPAddr, uiRemotePort, 
        pszBindingIPAddr ? pszBindingIPAddr : "0" , uiRemotePort );
	if(m_pSocketChn)
	{
        LOG2_DEBUG("ChnType(%d)  Close Socket: %s:%d => %s:%d .\n",
            GetChnType(),
            GetLocalIPAddrString(),GetLocalPort(),
            GetRemoteIPAddrString(),GetRemotePort()); 
        m_MutexSend.Lock();
        ISocketChannel *pSocket = m_pSocketChn;
        m_pSocketChn = NULL;
        m_MutexSend.Unlock();
        if( pSocket )
        {
            pSocket->CloseChannelEx();
        }
	}

	if(NULL == m_pSocketChn)
	{
		if(m_pNetService)
		{
			if(GetProtocolType() == PROTOCOL_TYPE_TCP)
			{
				euPType = NET_PROTOCOL_TCP;
			}
			else
			{
				euPType = NET_PROTOCOL_UDP;
			}
            ISocketChannel *pSocket = NULL;
			iRet = m_pNetService->AddClientChannel(m_szRemoteIPAddr, 
													uiRemotePort, 
													pszBindingIPAddr, 
													uiBindingPort, 
													euPType, 
													&pSocket);
			if(iRet < 0 || NULL == pSocket)
			{
                LOG2_ERROR("ChnType(%d) Connect %s:%d bind:%s:%d protype:%d fail.", 
                    GetChnType(),
                    pszRemoteIPAddr, uiRemotePort, 
                    pszBindingIPAddr ? pszBindingIPAddr : "0" , uiRemotePort,(int) euPType );
				return -1;
			}
            SetSocketChn( pSocket, NET_CHANNEL_STATUS_ACTIVE );

            LOG2_DEBUG("ChnType(%d)  Connect Socket: %s:%d => %s:%d  OK.\n",
                GetChnType(),
                GetLocalIPAddrString(),GetLocalPort(),
                GetRemoteIPAddrString(),GetRemotePort()); 
		}
		else
		{
            CMM_ASSERT(0);
			return -1;
		}
	}
	else
	{
		iRet = m_pSocketChn->ReConnect();
	}	
	return iRet;
}
static uint32_t _resetCache(s_tot2_Tmr_t* p_tmr, void* p_ctx)
{
    memset(p_ctx, 0x00, sizeof(s_sslSessCache_t));
    LOG2_INFO("Session Cache Element @ %p has " "been hit by reset timer", p_ctx);
    return 0;
}