-static void event_loop(void)
-{
- time_t delay = 0;
-
- 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);
- 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)
- delay = 1;
- else
- delay = IRCD_MIN(delay, TIMESEC);
- read_message(delay);
-
- 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);