diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dns.h | 11 | ||||
-rw-r--r-- | include/inspircd.h | 15 |
2 files changed, 10 insertions, 16 deletions
diff --git a/include/dns.h b/include/dns.h index f79121ab3..3d326a69c 100644 --- a/include/dns.h +++ b/include/dns.h @@ -84,19 +84,12 @@ class CoreExport CachedQuery * @param res The result data, an IP or hostname * @param ttl The time-to-live value of the query result */ - CachedQuery(const std::string &res, unsigned int ttl) : data(res) - { - expires = time(NULL) + ttl; - } + CachedQuery(const std::string &res, unsigned int ttl); /** Returns the number of seconds remaining before this * cache item has expired and should be removed. */ - int CalcTTLRemaining() - { - int n = (int)expires - (int)time(NULL); - return (n < 0 ? 0 : n); - } + int CalcTTLRemaining(); }; /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. diff --git a/include/inspircd.h b/include/inspircd.h index 3d1abdee4..89f0a08ee 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -52,6 +52,7 @@ #include <map> #include <bitset> #include <set> +#include <time.h> #include "inspircd_config.h" #include "inspircd_version.h" #include "typedefs.h" @@ -222,7 +223,7 @@ class serverstats timeval LastCPU; /** Time last sample was read */ - timeval LastSampled; + timespec LastSampled; /** The constructor initializes all the counts to zero */ serverstats() @@ -282,11 +283,7 @@ class CoreExport InspIRCd /** The current time, updated in the mainloop */ - time_t TIME; - - /** The time that was recorded last time around the mainloop - */ - time_t OLDTIME; + struct timespec TIME; /** A 64k buffer used to read socket data into * NOTE: update ValidateNetBufferSize if you change this @@ -446,7 +443,11 @@ class CoreExport InspIRCd * it is much faster than calling time() directly. * @return The current time as an epoch value (time_t) */ - time_t Time(); + inline time_t Time() { return TIME.tv_sec; } + /** The fractional time at the start of this mainloop iteration (nanoseconds) */ + inline long Time_ns() { return TIME.tv_nsec; } + /** Update the current time. Don't call this unless you have reason to do so. */ + void UpdateTime(); /** Bind all ports specified in the configuration file. * @return The number of ports bound without error |