コード例 #1
0
ファイル: ircd.c プロジェクト: Cloudxtreme/ircd-ratbox
void
set_time(void)
{
	struct timeval newtime;
	newtime.tv_sec = 0;
	newtime.tv_usec = 0;
#ifdef HAVE_GETTIMEOFDAY
	if(gettimeofday(&newtime, NULL) == -1)
	{
		ilog(L_MAIN, "Clock Failure (%d)", errno);
		sendto_realops_flags(UMODE_ALL, L_ALL,
				     "Clock Failure (%d), TS can be corrupted", errno);

		restart("Clock Failure");
	}
#else
	newtime.tv_sec = time(NULL);
	
#endif
	if(newtime.tv_sec < CurrentTime)
		set_back_events(CurrentTime - newtime.tv_sec);

	SystemTime.tv_sec = newtime.tv_sec;
	SystemTime.tv_usec = newtime.tv_usec;
}
コード例 #2
0
ファイル: ircd.c プロジェクト: BackupTheBerlios/shadowircd
void
set_time (void)
{
  static char to_send[200];
  struct timeval newtime;
  newtime.tv_sec = 0;
  newtime.tv_usec = 0;

  if (gettimeofday (&newtime, NULL) == -1)
    {
      ilog (L_ERROR, "Clock Failure (%d)", errno);
      sendto_realops_flags (UMODE_ALL, L_ALL,
			    "Clock Failure (%d), TS can be corrupted", errno);
      restart ("Clock Failure");
    }

  if (newtime.tv_sec < CurrentTime)
    {
      ircsprintf (to_send, "System clock is running backwards - (%lu < %lu)",
		  (unsigned long) newtime.tv_sec,
		  (unsigned long) CurrentTime);
      report_error (L_ALL, to_send, me.name, 0);
      set_back_events (CurrentTime - newtime.tv_sec);
    }

  SystemTime.tv_sec = newtime.tv_sec;
  SystemTime.tv_usec = newtime.tv_usec;
}
コード例 #3
0
ファイル: ircd.c プロジェクト: codemstr/eircd-hybrid-8
void
set_time(void)
{
  struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 };

  if (gettimeofday(&newtime, NULL) == -1)
  {
    ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted",
         strerror(errno));
    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                         "Clock Failure (%s), TS can be corrupted",
                         strerror(errno));
    server_die("Clock Failure", 1);
  }

  if (newtime.tv_sec < CurrentTime)
  {
    ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)",
         (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
                         "System clock is running backwards - (%lu < %lu)",
                         (unsigned long)newtime.tv_sec,
                         (unsigned long)CurrentTime);
    set_back_events(CurrentTime - newtime.tv_sec);
  }

  SystemTime.tv_sec  = newtime.tv_sec;
  SystemTime.tv_usec = newtime.tv_usec;
}

static void
io_loop(void)
{
  while (1)
  {
    if (listing_client_list.head)
    {
      dlink_node *node = NULL, *node_next = NULL;
      DLINK_FOREACH_SAFE(node, node_next, listing_client_list.head)
        safe_list_channels(node->data, 0);
    }

    /* Run pending events */
    event_run();

    comm_select();
    exit_aborted_clients();
    free_exited_clients();

    /* Check to see whether we have to rehash the configuration .. */
    if (dorehash)
    {
      conf_rehash(1);
      dorehash = 0;
    }

    if (doremotd)
    {
      motd_recache();
      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "Got signal SIGUSR1, reloading motd file(s)");
      doremotd = 0;
    }
  }
}

/* initalialize_global_set_options()
 *
 * inputs       - none
 * output       - none
 * side effects - This sets all global set options needed
 */
static void
initialize_global_set_options(void)
{
  GlobalSetOptions.maxclients = ConfigServerInfo.default_max_clients;
  GlobalSetOptions.autoconn = 1;
  GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
  GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
  GlobalSetOptions.floodcount = ConfigGeneral.default_floodcount;
  GlobalSetOptions.joinfloodcount = ConfigChannel.default_join_flood_count;
  GlobalSetOptions.joinfloodtime = ConfigChannel.default_join_flood_time;

  split_servers = ConfigChannel.default_split_server_count;
  split_users   = ConfigChannel.default_split_user_count;

  if (split_users && split_servers && (ConfigChannel.no_create_on_split ||
                                       ConfigChannel.no_join_on_split))
  {
    splitmode     = 1;
    splitchecking = 1;
  }

  GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
}