Ejemplo n.º 1
0
// 这个函数很重要!千万不能删
BOOL  CUnkownReport::CheckInDB( CReportFile& rfile )
{
    BOOL    bRet = FALSE;

    m_reportFileDB.QueryFileInfo( 
        rfile.m_strFilePath, 
        bRet, 
        rfile
        );
    if ( bRet )
    {
        if ( CheckExpired( rfile ) )
        {
            m_reportFileDB.RemoveFileInfo( rfile );
            bRet = FALSE;
        }
    }

    return bRet;
}
Ejemplo n.º 2
0
/*
 功能描述    : 开始服务
 返回值      : 成功为0,失败为-1
 参数        : 无
 日期        : 2015年5月26日 15:45:53
*/
int Session::Serve()
{
    struct sockaddr_un client_address;
    int bytes_received = 0;
    static char buf[BUF_SIZE];
    socklen_t address_length = 0;

    while (1)
    {
        memset(&client_address,0,sizeof(client_address));
        bytes_received = recvfrom(socket_fd, buf, BUF_SIZE, 0,
            (struct sockaddr *) &client_address,
            &address_length);

        if (0 < bytes_received)
        {
            if (0 != strcmp(client_address.sun_path, ClientSockPath))
            {
                printf("ci client sock path wrong:%s\n",client_address.sun_path);
                continue;
            }
        }
        /*
         * 若session过期则进行回收并重新利用
         * 因为recvfrom超时后会返回,所以保证了当链接中断时,内存当中的数据很快被同步到硬盘上
         */
        if (CheckExpired() || ConsumeManualRecycle())
        {
            Recycle();
        }
        if (0 < bytes_received)
        {
            Write(buf, bytes_received);
            gettimeofday(&last_ac_time,NULL);
        }
    }
    return 0;
}