From 69f280701b651fcbdc22f68db1714c384b9098f4 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 16 Jul 2006 21:28:09 +0000 Subject: Tweaks for nonblocking dns git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4432 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/dns.cpp') diff --git a/src/dns.cpp b/src/dns.cpp index f2acf05a6..0347caaae 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -851,6 +851,8 @@ std::string DNS::GetResultIP() void* dns_task(void* arg) { userrec* u = (userrec*)arg; + int thisfd = u->fd; + log(DEBUG,"DNS thread for user %s",u->nick); DNS dns1; DNS dns2; @@ -872,18 +874,22 @@ void* dns_task(void* arg) usleep(100); } ip = dns2.GetResultIP(); - if (ip == std::string((char*)inet_ntoa(u->ip4))) + if (ip == std::string(inet_ntoa(u->ip4))) { if (host.length() < 160) { - strcpy(u->host,host.c_str()); - strcpy(u->dhost,host.c_str()); + if ((fd_ref_table[thisfd] == u) && (fd_ref_table[thisfd])) + { + strcpy(u->host,host.c_str()); + strcpy(u->dhost,host.c_str()); + } } } } } } - u->dns_done = true; + if ((fd_ref_table[thisfd] == u) && (fd_ref_table[thisfd])) + u->dns_done = true; return NULL; } #endif -- cgit v1.2.3