-
-/*----------------------------------------------------------------------------
- * event_loop
- *--------------------------------------------------------------------------*/
-static void event_loop(void) {
- time_t nextdnscheck = 0;
- time_t delay = 0;
-
- thisServer.running = 1;
- while (thisServer.running) {
- /* We only want to connect if a connection is due, not every time through.
- * Note, if there are no active C lines, this call to Tryconnections is
- * made once only; it will return 0. - avalon
- */
- if (nextconnect && CurrentTime >= nextconnect)
- nextconnect = try_connections();
-
- /* DNS checks. One to timeout queries, one for cache expiries. */
- nextdnscheck = timeout_resolver(CurrentTime);
-
- /* Take the smaller of the two 'timed' event times as the time of next
- * event (stops us being late :) - avalon
- * WARNING - nextconnect can return 0!
- */
- if (nextconnect)
- delay = IRCD_MIN(nextping, nextconnect);
- else
- delay = nextping;
-
- delay = IRCD_MIN(nextdnscheck, delay) - CurrentTime;
-
- /* Adjust delay to something reasonable [ad hoc values] (one might think
- * something more clever here... --msa) We don't really need to check that
- * often and as long as we don't delay too long, everything should be ok.
- * waiting too long can cause things to timeout... i.e. PINGS -> a
- * disconnection :( - avalon
- */
- if (delay < 1)
- read_message(1);
- else
- read_message(IRCD_MIN(delay, TIMESEC));
-
- Debug((DEBUG_DEBUG, "Got message(s)"));
-
- /* ...perhaps should not do these loops every time, but only if there is
- * some chance of something happening (but, note that conf->hold times may
- * be changed elsewhere--so precomputed next event time might be too far
- * away... (similarly with ping times) --msa
- */
- if (CurrentTime >= nextping)
- nextping = check_pings();
-
- /* timeout pending queries that haven't been responded to */
- timeout_auth_queries(CurrentTime);
-
- ip_registry_expire();
-
- if (GlobalRehashFlag) {
- rehash(&me, 1);
- GlobalRehashFlag = 0;
- }
-
- if (GlobalRestartFlag)
- server_restart("caught signal: SIGINT");
- }
-}
-
-
-/*----------------------------------------------------------------------------
- * check_file_access: random helper function to make sure that a file is
- * accessible in a certain way, and complain if not.
- *--------------------------------------------------------------------------*/
+/** Check that we have access to a particular file.
+ * If we do not have access to the file, complain on stderr.
+ * @param[in] path File name to check for access.
+ * @param[in] which Configuration character associated with file.
+ * @param[in] mode Bitwise combination of R_OK, W_OK, X_OK and/or F_OK.
+ * @return Non-zero if we have the necessary access, zero if not.
+ */