diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.cpp | 8 | ||||
-rw-r--r-- | src/inspircd.cpp | 11 | ||||
-rw-r--r-- | src/users.cpp | 4 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index f02c4bfcc..e47680702 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -50,7 +50,9 @@ using namespace std; #include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> +#ifdef THREADED_DNS #include <pthread.h> +#endif #ifndef RUSAGE_SELF #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN -1 @@ -1724,11 +1726,17 @@ void handle_nick(char **parameters, int pcnt, userrec *user) //if (user->dns_done) // log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick); +#ifdef THREADED_DNS // initialize their dns lookup thread if (pthread_create(&user->dnsthread, NULL, dns_task, (void *)user) != 0) { log(DEBUG,"Failed to create DNS lookup thread for user %s",user->nick); } +#else + user->dns_done = (!lookup_dns(user->nick)); + if (user->dns_done) + log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick); +#endif } if (user->registered == 3) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 65b43fa37..271332f70 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -51,7 +51,9 @@ using namespace std; #include <vector> #include <deque> #include <sched.h> +#ifdef THREADED_DNS #include <pthread.h> +#endif #include "users.h" #include "ctables.h" #include "globals.h" @@ -1330,6 +1332,7 @@ void AddWhoWas(userrec* u) } } +#ifdef THREADED_DNS void* dns_task(void* arg) { userrec* u = (userrec*)arg; @@ -1372,6 +1375,7 @@ void* dns_task(void* arg) u->dns_done = true; return NULL; } +#endif /* add a client connection to the sockets list */ void AddClient(int socket, char* host, int port, bool iscached, char* ip) @@ -1610,7 +1614,12 @@ std::string GetVersionString() v2 = strtok_r(s1," ",&savept); s1 = savept; char socketengine[] = engine_name; - snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s (O=%lu) [SE=%s]",VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION,socketengine); +#ifdef THREADED_DNS + char dnsengine[] = "multithread"; +#else + char dnsengine[] = "singlethread"; +#endif + snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s [FLAGS=%lu,%s,%s]",VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION,socketengine,dnsengine); return versiondata; } diff --git a/src/users.cpp b/src/users.cpp index c78eb4793..19d6a37f4 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -22,8 +22,10 @@ using namespace std; #include "users.h" #include "inspircd.h" #include <stdio.h> +#ifdef THREADED_DNS #include <pthread.h> #include <signal.h> +#endif #include "inspstring.h" #include "helperfuncs.h" @@ -64,11 +66,13 @@ userrec::userrec() userrec::~userrec() { +#ifdef THREADED_DNS // for local clients, clean up their dns thread if (!strcmp(this->server,ServerName)) { pthread_kill(this->dnsthread,9); } +#endif } void userrec::CloseSocket() |