int Comm_Timer_Handler::handle_timeout(const ZCE_Time_Value &now_time, const void *act /*= 0*/) { ZCE_UNUSED_ARG(act); // 定时更新时间 update_time(now_time); // reload配置 notify_reload(); // 处理监控 check_monitor(now_time); return SOAR_RET::SOAR_RET_SUCC; }
//超时处理 int Server_Timer_Base::timer_timeout(const ZCE_Time_Value &now_time, const void *act ) { ZCE_UNUSED_ARG(act); //记录当前时间, now_time_ = now_time; const int timeid = *(static_cast<const int *>(act)); if (SERVER_TIMER_ID[0] == timeid) { ++heartbeat_counter_; heart_total_mesc_ = heartbeat_counter_ * heart_precision_.total_msec(); // 处理监控 check_monitor(now_time); } return 0; }
int main(int argc, char *argv[]) { int monsock; int become_daemon,n; sigset_t blockset; become_daemon = 0; while ((n = getopt(argc, argv, "dlv")) != -1) { switch (n) { case 'd': become_daemon = TRUE; break; case 'v': printf("\nldsped logcall version %s\n", LOGCALL_VERSION); printf ("Copyright (C) 2010 ON7LDS. All rights reserved.\n\n"); return 0; case '?': case ':': fprintf(stderr, "usage: ldsped [-d] [-v]\n"); return 1; } } writelog(0, "ldsped logcall v%s starting ...",LOGCALL_VERSION); // ------------------------------ start program ----------------------------------------- if (become_daemon) { if (!daemon_start(FALSE)) { writelog(0, "ldsped: cannot become a daemon"); return 1; } else { fclose(stdout); fclose(stderr); fclose(stdin); } } else printf("Started in console mode.\n"); // ------------------------------------------- debug ------------------------------------------- // file1 = fopen("/tmp/F1", "a"); // file2 = fopen("/tmp/F2", "a"); // ------------------------------------------- debug ------------------------------------------- // ------------------------------ initialising ------------------------------------------ init_ax_config_calls(); // Set some signal handlers signal(SIGPIPE, SIG_IGN); signal(SIGTERM, terminate); signal(SIGUSR1, signal_action_proc); signal(SIGUSR2, signal_action_proc); sigemptyset(&blockset); sigaddset(&blockset,SIGUSR1); sigaddset(&blockset,SIGUSR2); sigprocmask(SIG_BLOCK, &blockset, NULL); // Open socket for monitoring traffic if ((monsock = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) { // writelog(0, "Error opening monitor socket: m/%s", strerror(errno)); exit(1); } fcntl(monsock, F_SETFL, O_NONBLOCK); // writelog(6,"========> Open fd %i in main",monsock); // ------------------------------ start main loop --------------------------------------- while (1) { // check if there is data on the AX25 socket check_monitor(monsock); // only process the signals here. We do not want to interrupt // the functions above or the accompaying systemcalls sigprocmask(SIG_UNBLOCK, &blockset, NULL); if (signal_action == SIGUSR1) { dump_info(); signal_action = 0; } if (signal_action == SIGUSR2) { ; signal_action = 0; } sigprocmask(SIG_BLOCK, &blockset, NULL); } // end main while loop close(monsock); closelog(); return 0; }