From 6e08ce6bfd1da11569cbdb78b065f62a19bf56f3 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 1 Apr 2005 23:00:39 +0000 Subject: Turned an unstable vector into an array git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@946 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dnsqueue.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp index cf1fb7484..6d5c37405 100644 --- a/src/dnsqueue.cpp +++ b/src/dnsqueue.cpp @@ -158,7 +158,6 @@ extern user_hash clientlist; extern chan_hash chanlist; extern user_hash whowas; extern command_table cmdlist; -extern address_cache IP; extern ClassVector Classes; @@ -175,6 +174,14 @@ public: resolver = NULL; } + void Reset() + { + strcpy(u,""); + if (resolver) + delete resolver; + resolver = NULL; + } + ~Lookup() { if (resolver) @@ -204,8 +211,11 @@ public: usr = Find(u); if (usr) { - log(DEBUG,"Applying hostname lookup to %s: %s",usr->nick,hostname.c_str()); - if (hostname != "") + if (usr->registered == 7) + { + return true; + } + if ((hostname != "") && (usr->registered != 7)) { strlcpy(usr->host,hostname.c_str(),MAXBUF); WriteServ(usr->fd,"NOTICE Auth :Resolved your hostname: %s",hostname.c_str()); @@ -235,9 +245,7 @@ public: } }; -typedef std::deque dns_queue; - -dns_queue dnsq; +Lookup dnsq[MAXBUF]; bool lookup_dns(std::string nick) { @@ -248,8 +256,14 @@ bool lookup_dns(std::string nick) log(DEBUG,"Queueing DNS lookup for %s",u->nick); WriteServ(u->fd,"NOTICE Auth :Looking up your hostname..."); Lookup L(nick); - dnsq.push_back(L); - return true; + for (int j = 0; j < MAXBUF; j++) + { + if (!dnsq[j].GetFD()) + { + dnsq[j] = L; + return true; + } + } } return false; } @@ -257,16 +271,15 @@ bool lookup_dns(std::string nick) void dns_poll() { // do we have items in the queue? - if (dnsq.size()) + for (int j = 0; j < MAXBUF; j++) { // are any ready, or stale? - if (dnsq[0].Done() || (!dnsq[0].GetFD())) + if (dnsq[j].GetFD()) { - if (dnsq[0].GetFD()) + if (dnsq[j].Done()) { - log(DEBUG,"****** DNS lookup for fd %d is complete. ******",dnsq[0].GetFD()); + dnsq[j].Reset(); } - dnsq.pop_front(); } } } -- cgit v1.2.3