Пример #1
0
void CNetBackend::socket_check_cb(ev::timer &w, int32 revents)
{
    if ( EV_ERROR & revents )
    {
        GERROR() << "check socket connect timeout call back error:" << strerror(errno) << "\n";
        w.stop();

        abort_work( "socket_check_cb fail" );
    }

    int64 _now = ev_now(loop);
    CTcpSocket *psocket = null;

    vector<CTcpSocket *>::iterator itr = m_tcp_sockets.begin();
    while ( itr != m_tcp_sockets.end() )
    {
        psocket = *itr;

        itr ++;

        if ( !psocket )  //this fd not use
            continue;

        if ( ES_CONNECTED == psocket->get_socket_status()
             && _now - psocket->get_connect_time() > DISCONNECT_TIMEOUT )
        {
            psocket->close_socket();  //该状态未与游戏服建立连接,可以直接关闭
            psocket->set_socket_status( ES_NONE );
        }
    }
}
Пример #2
0
Файл: x0d.cpp Проект: crnt/x0
void XzeroHttpDaemon::quickShutdownTimeout(ev::timer&, int)
{
    log(x0::Severity::warn, "Quick shutdown timed out. Terminating.");

    ev_ref(loop_);
    terminationTimeout_.stop();

    ev_break(loop_, ev::ALL);
}
Пример #3
0
/**
 * @brief CLogBackend::backend
 * @param w
 * @param revents
 *
 * 1.处理缓存的日志
 *    (1)日志超量需要写入文件
 *    (2)日志超时需要写入文件
 * 2.从共享内存读取日志,try_lock失败一定次数后强制阻塞等待锁定
 */
void CLogBackend::backend(ev::timer &w, int32 revents)
{
    if ( EV_ERROR & revents )
    {
        GERROR() << "backend error:" << strerror(errno) << "\n";
        w.stop();
    }

    CBackend::backend();

    m_log_worker.read_shm_log();

    //TODO 写入文件
}