]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Remove check that very rarely equates to true
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 57c23b3286dbcf4257436f3703ded1a21175e9bc..a2b4e0d92e2c1e7ea67917c9a3d06196c5787752 100644 (file)
@@ -45,9 +45,6 @@
 #include <fstream>
 #include <vector>
 #include <deque>
-#ifdef THREADED_DNS
-#include <pthread.h>
-#endif
 #include "users.h"
 #include "ctables.h"
 #include "globals.h"
@@ -59,7 +56,6 @@
 #include "commands.h"
 #include "xline.h"
 #include "inspstring.h"
-#include "dnsqueue.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "socketengine.h"
@@ -238,7 +234,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
 {
        this->Start();
        module_sockets.clear();
-       init_dns();
        this->startup_time = time(NULL);
        srand(time(NULL));
        log(DEBUG,"*** InspIRCd starting up!");
@@ -336,11 +331,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
 std::string InspIRCd::GetVersionString()
 {
        char versiondata[MAXBUF];
-#ifdef THREADED_DNS
-       char dnsengine[] = "multithread";
-#else
-       char dnsengine[] = "singlethread";
-#endif
+       char dnsengine[] = "singlethread-object";
        if (*Config->CustomVersion)
        {
                snprintf(versiondata,MAXBUF,"%s %s :%s",VERSION,Config->ServerName,Config->CustomVersion);
@@ -825,31 +816,16 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                        break;
 
                        case X_ESTAB_DNS:
-                               /* When we are using single-threaded dns,
-                                * the sockets for dns end up in our mainloop.
-                                * When we are using multi-threaded dns,
-                                * each thread has its own basic poll() loop
-                                * within it, making them 'fire and forget'
-                                * and independent of the mainloop.
-                                */
-#ifndef THREADED_DNS
-                               log(DEBUG,"Type: X_ESTAB_DNS: fd=%d",activefds[activefd]);
-                               dns_poll(activefds[activefd]);
-#endif
-                       break;
-
-                       case X_ESTAB_CLASSDNS:
                                /* Handles instances of the Resolver class,
-                                * a simple class extended by modules for
+                                * a simple class extended by modules and the core for
                                 * nonblocking resolving of addresses.
                                 */
-
-                               dns_deal_with_classes(activefds[activefd]);
+                               this->Res->MarshallReads(activefds[activefd]);
                        break;
 
                        case X_LISTEN:
 
-                               log(DEBUG,"Type: X_LISTEN_MODULE: fd=%d",activefds[activefd]);
+                               log(DEBUG,"Type: X_LISTEN: fd=%d",activefds[activefd]);
 
                                /* It's a listener */
                                uslen = sizeof(sock_us);
@@ -886,15 +862,17 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                                        }
                                        stats->statsAccept++;
 #ifdef IPV6
+                                       log(DEBUG,"Add ipv6 client");
                                        AddClient(incomingSockfd, in_port, false, client.sin6_addr);
 #else
+                                       log(DEBUG,"Add ipv4 client");
                                        AddClient(incomingSockfd, in_port, false, client.sin_addr);
 #endif
-                                       log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
+                                       log(DEBUG,"Adding client on port %d fd=%d",in_port,incomingSockfd);
                                }
                                else
                                {
-                                       log(DEBUG,"Accept failed on fd %lu: %s",(unsigned long)incomingSockfd,strerror(errno));
+                                       log(DEBUG,"Accept failed on fd %d: %s",incomingSockfd,strerror(errno));
                                        shutdown(incomingSockfd,2);
                                        close(incomingSockfd);
                                        stats->statsRefused++;
@@ -918,6 +896,8 @@ int InspIRCd::Run()
 {
        /* Until THIS point, ServerInstance == NULL */
        
+       this->Res = new DNS();
+
        LoadAllModules(this);
 
        /* Just in case no modules were loaded - fix for bug #101 */
@@ -960,61 +940,14 @@ int InspIRCd::Run()
 
 int main(int argc, char** argv)
 {
-       /* TEST SUITE FOR TOKENSTREAM
-        *
-        * Expected output:
-        * 
-        * String: 'PRIVMSG #test FOO BAR'
-        * Token 0 = 'PRIVMSG'
-        * Token 1 = '#test'
-        * Token 2 = 'FOO'
-        * Token 3 = 'BAR'
-        * String: 'PRIVMSG #test :FOO BAR BAZ'
-        * Token 0 = 'PRIVMSG'
-        * Token 1 = '#test'
-        * Token 2 = 'FOO BAR BAZ'
-        * String: ':PRIVMSG #test :FOO BAR BAZ'
-        * Token 0 = ':PRIVMSG'
-        * String: 'AAAAAAA'
-        * Token 0 = 'AAAAAAA'
-        * String: ''
-        * NumItems = 0
-        *
-       std::string a = "PRIVMSG #test FOO BAR";
-       printf("String: '%s'\n",a.c_str());
-       irc::tokenstream test(a);
-       printf("Token 0 = '%s'\n",test.GetToken().c_str());
-       printf("Token 1 = '%s'\n",test.GetToken().c_str());
-       printf("Token 2 = '%s'\n",test.GetToken().c_str());
-       printf("Token 3 = '%s'\n",test.GetToken().c_str());
-       printf("Token 4 = '%s'\n",test.GetToken().c_str());
-
-       std::string b = "PRIVMSG #test :FOO BAR BAZ";
-       printf("String: '%s'\n",b.c_str());
-       irc::tokenstream test2(b);
-       printf("Token 0 = '%s'\n",test2.GetToken().c_str());
-       printf("Token 1 = '%s'\n",test2.GetToken().c_str());
-       printf("Token 2 = '%s'\n",test2.GetToken().c_str());
-       printf("Token 3 = '%s'\n",test2.GetToken().c_str());
-
-       std::string c = ":PRIVMSG #test :FOO BAR BAZ";
-       printf("String: '%s'\n",c.c_str());
-       irc::tokenstream test3(c);
-       printf("Token 0 = '%s'\n",test3.GetToken().c_str());
-
-       c = "AAAAAAA";
-       printf("String: '%s'\n",c.c_str());
-       irc::tokenstream test4(c);
-       printf("Token 0 = '%s'\n",test4.GetToken().c_str());
-       printf("Token 1 = '%s'\n",test4.GetToken().c_str());
-
-       c = "";
-       printf("String: '%s'\n",c.c_str());
-       irc::tokenstream test5(c);
-       printf("Token 0 = '%s'\n",test5.GetToken().c_str());
-
-       exit(0);
-       */
+       /* This is a MatchCIDR() test suite -
+       printf("Should be 0: %d\n",MatchCIDR("127.0.0.1","1.2.3.4/8"));
+       printf("Should be 1: %d\n",MatchCIDR("127.0.0.1","127.0.0.0/8"));
+       printf("Should be 1: %d\n",MatchCIDR("127.0.0.1","127.0.0.0/18"));
+       printf("Should be 0: %d\n",MatchCIDR("3ffe::0","2fc9::0/16"));
+       printf("Should be 1: %d\n",MatchCIDR("3ffe:1:3::0", "3ffe:1::0/32"));
+       exit(0); */
+
        try
        {
                ServerInstance = new InspIRCd(argc, argv);