示例#1
0
文件: event.c 项目: kghost/lldpd
/* Initialize libevent and start the event loop */
void
levent_loop(struct lldpd *cfg)
{
	levent_init(cfg);
	lldpd_loop(cfg);

	/* libevent loop */
	do {
		if (event_base_got_break(cfg->g_base) ||
		    event_base_got_exit(cfg->g_base))
			break;
#ifdef USE_SNMP
		if (cfg->g_snmp) {
			/* We don't use delegated requests (request
			   whose answer is delayed). However, we keep
			   the call here in case we use it some
			   day. We don't call run_alarms() here. We do
			   it on timeout only. */
			netsnmp_check_outstanding_agent_requests();
			levent_snmp_update(cfg);
		}
#endif
	} while (event_base_loop(cfg->g_base, EVLOOP_ONCE) == 0);

#ifdef USE_SNMP
	if (cfg->g_snmp)
		agent_shutdown();
#endif /* USE_SNMP */

}
示例#2
0
void EventLoop::run()
{
    __in_event_loop__ = true;

    // Block SIGPIPE in the event loop because we can not force
    // underlying implementations such as SSL bufferevents to use
    // MSG_NOSIGNAL.
    SUPPRESS(SIGPIPE) {
        do {
            int result = event_base_loop(base, EVLOOP_ONCE);
            if (result < 0) {
                LOG(FATAL) << "Failed to run event loop";
            } else if (result > 0) {
                // All events are handled, continue event loop.
                continue;
            } else {
                CHECK_EQ(0, result);
                if (event_base_got_break(base)) {
                    break;
                } else if (event_base_got_exit(base)) {
                    break;
                }
            }
        } while (true);
    }

    __in_event_loop__ = false;
}
示例#3
0
文件: GuNET_Server.c 项目: Vild/GuNET
GuNET_Server_Error_t GuNET_Server_RunLoop(GuNET_Server_t * server) {
	check(!server, GuNET_SERVER_ERROR_INVALID_ARGS);

	event_base_dispatch(server->base);

	if (event_base_got_exit(server->base))
		return GuNET_SERVER_ERROR_GOT_EXIT_EVENT;
	else
		return GuNET_SERVER_ERROR_NONE;
}
示例#4
0
文件: GuNET_Server.c 项目: Vild/GuNET
GuNET_Server_Error_t GuNET_Server_Run(GuNET_Server_t * server) {
	check(!server, GuNET_SERVER_ERROR_INVALID_ARGS);

	event_base_loop(server->base, EVLOOP_NONBLOCK);

	if (event_base_got_exit(server->base))
		return GuNET_SERVER_ERROR_GOT_EXIT_EVENT;
	else
		return GuNET_SERVER_ERROR_NONE;
}
示例#5
0
文件: GuNET_Server.c 项目: Vild/GuNET
GuNET_Server_Error_t GuNET_Server_RunTimeout(GuNET_Server_t * server,
		int milliseconds) {
	struct timeval tv;
	check(!server, GuNET_SERVER_ERROR_INVALID_ARGS);

	tv.tv_sec = milliseconds / 1000;
	tv.tv_usec = ((int) (milliseconds % 1000)) * 1000;

	event_base_loopexit(server->base, &tv);

	if (event_base_got_exit(server->base))
		return GuNET_SERVER_ERROR_GOT_EXIT_EVENT;
	else
		return GuNET_SERVER_ERROR_NONE;
}
示例#6
0
void EventLoop::run()
{
  __in_event_loop__ = true;

  do {
    int result = event_base_loop(base, EVLOOP_ONCE);
    if (result < 0) {
      LOG(FATAL) << "Failed to run event loop";
    } else if (result > 0) {
      // All events are handled, continue event loop.
      continue;
    } else {
      CHECK_EQ(0, result);
      if (event_base_got_break(base)) {
        break;
      } else if (event_base_got_exit(base)) {
        break;
      }
    }
  } while (true);

  __in_event_loop__ = false;
}