Esempio n. 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 );
        }
    }
}
Esempio n. 2
0
File: x0d.cpp Progetto: 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);
}
Esempio n. 3
0
	void setup_step(const x0::FlowParams& args, x0::FlowValue& result)
	{
		if (args.empty()) {
			result.set(step_);
			return;
		}

		args[0].load(step_);

		if (step_)
			evTimer_.set(step_, step_);

		checkStart();
	}
Esempio n. 4
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 写入文件
}
Esempio n. 5
0
File: x0d.cpp Progetto: crnt/x0
// stage-2 termination handler
void XzeroHttpDaemon::quickShutdownHandler(ev::sig& sig, int)
{
    log(x0::Severity::info, "%s received. shutting down NOW.", sig2str(sig.signum).c_str());

    if (!child_.pid) {
        // we are no garbage parent process
        sd_notify(0, "STATUS=Shutting down.");
    }

    // default to standard signal-handler
    ev_ref(loop_);
    sig.stop();

    // install shutdown timeout handler
    terminationTimeout_.set<XzeroHttpDaemon, &XzeroHttpDaemon::quickShutdownTimeout>(this);
    terminationTimeout_.start(10, 0);
    ev_unref(loop_);

    // kill active HTTP connections
    server_->kill();
}
Esempio n. 6
0
	void checkStart()
	{
		if (step_ > 0 && !filename_.empty()) {
			evTimer_.start();
		}
	}
Esempio n. 7
0
 tcp_si_map ()
 {
   ev_default_loop (0);
   cleaner.set<tcp_si_map, &tcp_si_map::cleaner_cb> (this);
   cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2);
 }