]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Second attempt at time() -> SI->Time(), now problems with the original were fixed...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 1 Nov 2008 23:02:23 +0000 (23:02 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 1 Nov 2008 23:02:23 +0000 (23:02 +0000)
Thanks Namegduf!
(Please test, all, valdebug etc, report odd behaviour/warnings!)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10783 e03df62e-2008-0410-955e-edbf42e46eb7

22 files changed:
include/bancache.h
include/u_listmode.h
src/bancache.cpp
src/commands/cmd_invite.cpp
src/dns.cpp
src/inspircd.cpp
src/modules/extra/m_sqllog.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/modules/extra/m_testclient.cpp
src/modules/m_callerid.cpp
src/modules/m_joinflood.cpp
src/modules/m_kicknorejoin.cpp
src/modules/m_messageflood.cpp
src/modules/m_nickflood.cpp
src/modules/m_randquote.cpp
src/modules/m_spanningtree/handshaketimer.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/utils.cpp
src/modules/m_timedbans.cpp
src/socketengine.cpp
src/users.cpp

index b6e037f79dde8e955c3f5e99cceba6b2c75277ae..7771feb75cd5ac48e40a16c67a9d2be010bcdbee 100644 (file)
@@ -45,7 +45,7 @@ class CoreExport BanCacheHit : public classbase
                this->Type = type;
                this->Reason = reason;
                this->IP = ip;
-               this->Expiry = time(NULL) + 86400; // a day. this might seem long, but entries will be removed as glines/etc expire.
+               this->Expiry = ServerInstance->Time() + 86400; // a day. this might seem long, but entries will be removed as glines/etc expire.
        }
 
        // overridden to allow custom time
@@ -55,7 +55,7 @@ class CoreExport BanCacheHit : public classbase
                this->Type = type;
                this->Reason = reason;
                this->IP = ip;
-               this->Expiry = time(NULL) + seconds;
+               this->Expiry = ServerInstance->Time() + seconds;
        }
 };
 
index 358ccbf8312346117ac15935afc95f9b9abe387c..6e654f64faec1db62ced00e505438f78f4361506 100644 (file)
 
 /** Get the time as a string
  */
-inline std::string stringtime()
+inline std::string stringtime(InspIRCd* Instance)
 {
        std::ostringstream TIME;
-       TIME << time(NULL); 
+       TIME << Instance->Time(); 
        return TIME.str();
 }
 
@@ -331,7 +331,7 @@ class ListModeBase : public ModeHandler
                                                        ListItem e;
                                                        e.mask = parameter;
                                                        e.nick = servermode ? ServerInstance->Config->ServerName : source->nick;
-                                                       e.time = stringtime();
+                                                       e.time = stringtime(ServerInstance);
 
                                                        el->push_back(e);
                                                        return MODEACTION_ALLOW;
index 826244b55bc2cddf89c40394f3bcee4f3f35d21e..9fe70cb41e9d1d678d6eaa8704c214c417b60631 100644 (file)
@@ -50,7 +50,7 @@ BanCacheHit *BanCacheManager::GetHit(const std::string &ip)
                return NULL; // free and safe
        else
        {
-               if (time(NULL) > i->second->Expiry)
+               if (ServerInstance->Time() > i->second->Expiry)
                {
                        ServerInstance->Logs->Log("BANCACHE", DEBUG, "Hit on " + ip + " is out of date, removing!");
                        RemoveHit(i->second);
@@ -137,7 +137,7 @@ void BanCacheManager::RehashCache()
                /* Safe to delete items here through iterator 'n' */
                BanCacheHit *b = n->second;
 
-               if (time(NULL) > b->Expiry)
+               if (ServerInstance->Time() > b->Expiry)
                {
                        /* we need to remove this one. */
                        delete b;
index ac9ad08f99edadb69f72d070437ff3bc0f741745..1a70fbe0e0b9a6e108235034dfffc18a8dea3f9a 100644 (file)
@@ -33,7 +33,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
                if (parameters.size() == 3)
                {
                        if (IS_LOCAL(user))
-                               timeout = time(NULL) + ServerInstance->Duration(parameters[2]);
+                               timeout = ServerInstance->Time() + ServerInstance->Duration(parameters[2]);
                        else
                                timeout = ConvToInt(parameters[2]);
                }
index 63b523bfda98069ef9ea957007e9eb4ffc84791f..85d620982630435ca0e604a5993a8b81e1ce998f 100644 (file)
@@ -126,7 +126,7 @@ class RequestTimeout : public Timer
        DNSRequest* watch;
        int watchid;
  public:
-       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id)
+       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, SI->Time()), ServerInstance(SI), watch(watching), watchid(id)
        {
        }
 
index 518b1b5bbdc80c5a9e037d78001861a3641e8e3f..c0391b6793ec0eb4a369e26af4f8db1f43ea2cbe 100644 (file)
@@ -443,6 +443,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->Modes = 0;
        this->Res = 0;
 
+       // Initialise TIME
+       this->TIME = time(NULL);
 
        memset(&server, 0, sizeof(server));
        memset(&client, 0, sizeof(client));
index e57e40354da514d0c1a24d50e2aac07f96acd4d4..a3f99535536c72eb4ec978177426f1111180fa3f 100644 (file)
@@ -28,6 +28,8 @@ std::map<unsigned long,QueryInfo*> active_queries;
 
 class QueryInfo
 {
+private:
+       InspIRCd* ServerInstance;
 public:
        QueryState qs;
        unsigned long id;
@@ -41,8 +43,9 @@ public:
        time_t date;
        bool insert;
 
-       QueryInfo(const std::string &n, const std::string &s, const std::string &h, unsigned long i, int cat)
+       QueryInfo(InspIRCd* Instance, const std::string &n, const std::string &s, const std::string &h, unsigned long i, int cat)
        {
+               ServerInstance = Instance;
                qs = FIND_SOURCE;
                nick = n;
                source = s;
@@ -50,7 +53,7 @@ public:
                id = i;
                category = cat;
                sourceid = nickid = hostid = -1;
-               date = time(NULL);
+               date = ServerInstance->Time();
                insert = false;
        }
 
@@ -250,7 +253,7 @@ class ModuleSQLLog : public Module
                SQLrequest req = SQLrequest(this, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % source);
                if(req.Send())
                {
-                       QueryInfo* i = new QueryInfo(nick, source, host, req.id, category);
+                       QueryInfo* i = new QueryInfo(ServerInstance, nick, source, host, req.id, category);
                        i->qs = FIND_SOURCE;
                        active_queries[req.id] = i;
                }
index adbd48fb64dcf44ebb74c8a63dde347d7a3ce6bc..cd0af7e8b3fa984f44a95089e2eac80a98df5aca 100644 (file)
@@ -903,7 +903,7 @@ class ModuleSSLGnuTLS : public Module
 
                /* Beware here we do not check for errors.
                 */
-               if ((gnutls_x509_crt_get_expiration_time(cert) < time(0)) || (gnutls_x509_crt_get_activation_time(cert) > time(0)))
+               if ((gnutls_x509_crt_get_expiration_time(cert) < ServerInstance->Time()) || (gnutls_x509_crt_get_activation_time(cert) > ServerInstance->Time()))
                {
                        certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
                }
index 389fffb85fca173d7123b38a2234abf28449cf01..796db66d7174cdf8ac95b599d396fbe9d4aa96a0 100644 (file)
@@ -871,7 +871,7 @@ class ModuleSSLOpenSSL : public Module
                        certinfo->data.insert(std::make_pair("fingerprint",irc::hex(md, n)));
                }
 
-               if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), time(NULL)) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), time(NULL)) == 0))
+               if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), ServerInstance->Time()) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), ServerInstance->Time()) == 0))
                {
                        certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
                }
index c5c07efc09dddf3d675f2d9262aaed5b34a6763e..d800709390f31215fdebb48b4977e0671cc68018 100644 (file)
@@ -40,7 +40,7 @@ public:
                if(target)
                {
                        SQLrequest foo = SQLrequest(this, target, "foo",
-                                       SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % time(NULL));
+                                       SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % ServerInstance->Time());
 
                        if(foo.Send())
                        {
index 0204ee77f0f0b4312e83fafda501cdea12bd2a7e..d8e50b280554adb9a255d9a86a8447660731f581 100644 (file)
@@ -338,7 +338,7 @@ public:
 
                if (i == dat->accepting.end())
                {
-                       time_t now = time(NULL);
+                       time_t now = ServerInstance->Time();
                        /* +g and *not* accepted */
                        user->WriteNumeric(716, "%s %s :is in +g mode (server-side ignore).", user->nick.c_str(), dest->nick.c_str());
                        if (now > (dat->lastnotify + (time_t)notify_cooldown))
index 33ba98aa410951b33f69c3e688e19ede82bd5222..40a007c2c8da0c2790c94e001a5f7f1a67896004 100644 (file)
@@ -33,7 +33,7 @@ class joinfloodsettings : public classbase
 
        joinfloodsettings(int b, int c) : secs(b), joins(c)
        {
-               reset = time(NULL) + secs;
+               reset = ServerInstance->Time() + secs;
                counter = 0;
                locked = false;
        };
@@ -41,10 +41,10 @@ class joinfloodsettings : public classbase
        void addjoin()
        {
                counter++;
-               if (time(NULL) > reset)
+               if (ServerInstance->Time() > reset)
                {
                        counter = 0;
-                       reset = time(NULL) + secs;
+                       reset = ServerInstance->Time() + secs;
                }
        }
 
@@ -62,7 +62,7 @@ class joinfloodsettings : public classbase
        {
                if (locked)
                {
-                       if (time(NULL) > unlocktime)
+                       if (ServerInstance->Time() > unlocktime)
                        {
                                locked = false;
                                return false;
@@ -78,7 +78,7 @@ class joinfloodsettings : public classbase
        void lock()
        {
                locked = true;
-               unlocktime = time(NULL) + 60;
+               unlocktime = ServerInstance->Time() + 60;
        }
 
 };
index cd027f089b9c56f1ec05cbc1826c9d324ddf188a..bf5e10595c38b2c2925c8f71520f1adf81d9d800 100644 (file)
@@ -141,7 +141,7 @@ public:
 
                                for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
                                {
-                                       if (iter->second > time(NULL))
+                                       if (iter->second > ServerInstance->Time())
                                        {
                                                if (iter->first == user)
                                                {
@@ -180,7 +180,7 @@ public:
                                dl = new delaylist;
                                chan->Extend("norejoinusers", dl);
                        }
-                       (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
+                       (*dl)[user] = ServerInstance->Time() + strtoint(chan->GetModeParameter('J'));
                }
        }
 
index c374c5346b0cd075aa550b408ca91d1b0875f756..53df408f696e6dcdc7bca05892cd410732a732e9 100644 (file)
@@ -19,6 +19,8 @@
  */
 class floodsettings : public classbase
 {
+ private:
+       InspIRCd *ServerInstance;
  public:
        bool ban;
        int secs;
@@ -26,10 +28,10 @@ class floodsettings : public classbase
        time_t reset;
        std::map<User*,int> counters;
 
-       floodsettings() : ban(0), secs(0), lines(0) {};
-       floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c)
+       floodsettings(InspIRCd *Instance) : ServerInstance(Instance), ban(0), secs(0), lines(0) {};
+       floodsettings(InspIRCd *Instance, bool a, int b, int c) : ServerInstance(Instance), ban(a), secs(b), lines(c)
        {
-               reset = time(NULL) + secs;
+               reset = ServerInstance->Time() + secs;
        };
 
        void addmessage(User* who)
@@ -43,10 +45,10 @@ class floodsettings : public classbase
                {
                        counters[who] = 1;
                }
-               if (time(NULL) > reset)
+               if (ServerInstance->Time() > reset)
                {
                        counters.clear();
-                       reset = time(NULL) + secs;
+                       reset = ServerInstance->Time() + secs;
                }
        }
 
@@ -140,7 +142,7 @@ class MsgFlood : public ModeHandler
                                        if (!channel->GetExt("flood", f))
                                        {
                                                parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" +ConvToStr(nsecs);
-                                               floodsettings *fs = new floodsettings(ban,nsecs,nlines);
+                                               floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
                                                channel->Extend("flood",fs);
                                                channel->SetMode('f', true);
                                                channel->SetModeParam('f', parameter.c_str(), true);
@@ -160,7 +162,7 @@ class MsgFlood : public ModeHandler
                                                        if ((((nlines != f->lines) || (nsecs != f->secs) || (ban != f->ban))) && (((nsecs > 0) && (nlines > 0))))
                                                        {
                                                                delete f;
-                                                               floodsettings *fs = new floodsettings(ban,nsecs,nlines);
+                                                               floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
                                                                channel->Shrink("flood");
                                                                channel->Extend("flood",fs);
                                                                channel->SetModeParam('f', cur_param.c_str(), false);
index 72e2831dae4f827aae4cc95c06bf305b667c41d9..4961e97a0f31e90730bd91c4db535f18008e3f6d 100644 (file)
@@ -33,7 +33,7 @@ class nickfloodsettings : public classbase
 
        nickfloodsettings(int b, int c) : secs(b), nicks(c)
        {
-               reset = time(NULL) + secs;
+               reset = ServerInstance->Time() + secs;
                counter = 0;
                locked = false;
        };
@@ -41,10 +41,10 @@ class nickfloodsettings : public classbase
        void addnick()
        {
                counter++;
-               if (time(NULL) > reset)
+               if (ServerInstance->Time() > reset)
                {
                        counter = 0;
-                       reset = time(NULL) + secs;
+                       reset = ServerInstance->Time() + secs;
                }
        }
 
@@ -62,7 +62,7 @@ class nickfloodsettings : public classbase
        {
                if (locked)
                {
-                       if (time(NULL) > unlocktime)
+                       if (ServerInstance->Time() > unlocktime)
                        {
                                locked = false;
                                return false;
@@ -78,7 +78,7 @@ class nickfloodsettings : public classbase
        void lock()
        {
                locked = true;
-               unlocktime = time(NULL) + 60;
+               unlocktime = ServerInstance->Time() + 60;
        }
 
 };
index c03b2777a59154ceb6f46b27595486dc6ca450e5..8092d516271dda0648ca11f1014e30f92592e052 100644 (file)
@@ -64,7 +64,7 @@ class ModuleRandQuote : public Module
 
                conf = new ConfigReader(ServerInstance);
                // Sort the Randomizer thingie..
-               srand(time(NULL));
+               srand(ServerInstance->Time());
 
                q_file = conf->ReadValue("randquote","file",0);
                prefix = conf->ReadValue("randquote","prefix",0);
index 44938bafa5c570259547e89e34270de44d9e8a61..facbf6c301424eda4e5b3b36898d2c536c82af7f 100644 (file)
@@ -27,7 +27,7 @@
 
 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
 
-HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, time(NULL)), Instance(Inst), sock(s), lnk(l), Utils(u)
+HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, Inst->Time()), Instance(Inst), sock(s), lnk(l), Utils(u)
 {
        thefd = sock->GetFd();
 }
index c3167b9b31a8bd9499901ccda8db398dc752c9a1..a286150b2d95f4e18c86d30baac26994ca145100 100644 (file)
@@ -67,7 +67,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
        bursting = false;
        VersionString.clear();
        ServerUserCount = ServerOperCount = 0;
-       this->SetNextPingTime(time(NULL) + Utils->PingFreq);
+       this->SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
        this->SetPingFlag();
        Warned = DupError = false;
        StartBurst = rtt = 0;
index 48d829f6f3cc78b943acb4d53ada4b0fecb25574..06851619c69c3b791ff242ec21d11d258f69997e 100644 (file)
@@ -536,7 +536,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
 
                }
 
-               L.NextConnectTime = time(NULL) + L.AutoConnect;
+               L.NextConnectTime = ServerInstance->Time() + L.AutoConnect;
 
                if (L.Name.find('.') == std::string::npos)
                        throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character");
index a10f90819e47580efda2db5026fa89b122a33523..5e0650a3d07f165584b8b0ca3bb7962fb3c3e2b8 100644 (file)
@@ -64,7 +64,7 @@ class CommandTban : public Command
                                TimedBan T;
                                std::string channelname = parameters[0];
                                long duration = ServerInstance->Duration(parameters[1]);
-                               unsigned long expire = duration + time(NULL);
+                               unsigned long expire = duration + ServerInstance->Time();
                                if (duration < 1)
                                {
                                        user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid ban time");
index 0a071796480cf78d731b559bc2fb1022ee9a8397..300a08bccca8c4c3fd2fcde7bfe020064e157a13 100644 (file)
@@ -96,7 +96,7 @@ void SocketEngine::WantWrite(EventHandler* eh)
 SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance)
 {
        TotalEvents = WriteEvents = ReadEvents = ErrorEvents = 0;
-       lastempty = time(NULL);
+       lastempty = ServerInstance->Time();
        indata = outdata = 0;
 }
 
@@ -263,9 +263,9 @@ void SocketEngine::RecoverFromFork()
 
 void SocketEngine::UpdateStats(size_t len_in, size_t len_out)
 {
-       if (lastempty != time(NULL))
+       if (lastempty != ServerInstance->Time())
        {
-               lastempty = time(NULL);
+               lastempty = ServerInstance->Time();
                indata = outdata = 0;
        }
        indata += len_in;
index 848f2a1eb23f1c60c78da4653b7bf8bbc6768f41..0a196d798a440c539ed092f9f40140a02501cafe 100644 (file)
@@ -398,7 +398,7 @@ const std::string& User::GetFullRealHost()
 
 bool User::IsInvited(const irc::string &channel)
 {
-       time_t now = time(NULL);
+       time_t now = ServerInstance->Time();
        InvitedList::iterator safei;
        for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
        {
@@ -420,7 +420,7 @@ bool User::IsInvited(const irc::string &channel)
 
 InvitedList* User::GetInviteList()
 {
-       time_t now = time(NULL);
+       time_t now = ServerInstance->Time();
        /* Weed out expired invites here. */
        InvitedList::iterator safei;
        for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
@@ -438,7 +438,7 @@ InvitedList* User::GetInviteList()
 
 void User::InviteTo(const irc::string &channel, time_t invtimeout)
 {
-       time_t now = time(NULL);
+       time_t now = ServerInstance->Time();
        if (invtimeout != 0 && now > invtimeout) return; /* Don't add invites that are expired from the get-go. */
        for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
        {