diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-12 12:49:12 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-12 12:49:12 +0000 |
commit | 2e816169a426511ec7c2a45b7bc7947358310b2d (patch) | |
tree | db312b948d3821367f96c80cf713aed3194ad583 | |
parent | 280f52aeae72a3383e1e10b2f2a5952e7b1413b7 (diff) |
Attempts to make DNS nicer with new socket engine
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2332 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/dns.h | 3 | ||||
-rw-r--r-- | include/dnsqueue.h | 2 | ||||
-rw-r--r-- | src/dns.cpp | 5 | ||||
-rw-r--r-- | src/dnsqueue.cpp | 10 | ||||
-rw-r--r-- | src/inspircd.cpp | 2 |
5 files changed, 15 insertions, 7 deletions
diff --git a/include/dns.h b/include/dns.h index f1c118909..63d5bb1fb 100644 --- a/include/dns.h +++ b/include/dns.h @@ -82,6 +82,9 @@ public: * to determine the status of the socket. */ bool HasResult(); + /** This method will return true if the lookup's fd matches the one provided + */ + bool HasResult(int fd); /** This method returns the result of your query as a string, depending upon wether you * called DNS::ReverseLookup() or DNS::ForwardLookup. */ diff --git a/include/dnsqueue.h b/include/dnsqueue.h index 8546b0f62..f251dcaa2 100644 --- a/include/dnsqueue.h +++ b/include/dnsqueue.h @@ -2,4 +2,4 @@ #include "users.h" bool lookup_dns(std::string nick); -void dns_poll(); +void dns_poll(int fdcheck); diff --git a/src/dns.cpp b/src/dns.cpp index a0e36e600..0fd8b5602 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -688,6 +688,11 @@ bool DNS::ForwardLookup(std::string host) return true; } +bool DNS::HasResult(int fd) +{ + return (fd == this->myfd); +} + bool DNS::HasResult() { log(DEBUG,"DNS: HasResult, fd=%d",this->myfd); diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp index e237de677..2e8cbaabb 100644 --- a/src/dnsqueue.cpp +++ b/src/dnsqueue.cpp @@ -134,14 +134,14 @@ public: return false; } - bool Done() + bool Done(int fdcheck) { if (hostname != "") { log(DEBUG,"Doing forward lookup here with host %s",hostname.c_str()); // doing forward lookup userrec* usr = NULL; - if (resolver2.HasResult()) + if (resolver2.HasResult(fdcheck)) { log(DEBUG,"resolver2 has result"); if (resolver2.GetFD() != 0) @@ -193,7 +193,7 @@ public: { // doing reverse lookup userrec* usr = NULL; - if (resolver1.HasResult()) + if (resolver1.HasResult(fdcheck)) { usr = Find(u); if ((usr) && (usr->dns_done)) @@ -267,7 +267,7 @@ bool lookup_dns(std::string nick) return false; } -void dns_poll() +void dns_poll(int fdcheck) { // do we have items in the queue? for (int j = 0; j <= max_fd_alloc; j++) @@ -275,7 +275,7 @@ void dns_poll() // are any ready, or stale? if (dnsq[j].GetFD()) { - if (dnsq[j].Done()) + if (dnsq[j].Done(fdcheck)) { dnsq[j].Reset(); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 5a9493b0c..404005ba3 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2710,7 +2710,7 @@ int InspIRCd(char** argv, int argc) { log(DEBUG,"Got a ready socket of type X_ESTAB_DNS"); #ifndef THREADED_DNS - dns_poll(); + dns_poll(activefds[activefd]); #endif } else if (SE->GetType(activefds[activefd]) == X_LISTEN) |