]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_mysql.cpp
Commit patch from danieldg that makes a ton of stuff const-safe for latest warn-happy...
[user/henk/code/inspircd.git] / src / modules / extra / m_mysql.cpp
index 53d852f72994a5646d07279b91ec413282339375..8fa717f78ffad235ba10330874302aaaddf1d890 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -25,6 +25,7 @@
 /* $CompileFlags: exec("mysql_config --include") */
 /* $LinkerFlags: exec("mysql_config --libs_r") rpath("mysql_config --libs_r") */
 /* $ModDep: m_sqlv2.h */
+/* $NoPedantic */
 
 /* THE NONBLOCKING MYSQL API!
  * 
@@ -98,7 +99,7 @@ class MySQLresult : public SQLresult
        int rows;
  public:
 
-       MySQLresult(Module* self, Module* to, MYSQL_RES* res, int affected_rows, unsigned int id) : SQLresult(self, to, id), currentrow(0), fieldmap(NULL)
+       MySQLresult(Module* self, Module* to, MYSQL_RES* res, int affected_rows, unsigned int rid) : SQLresult(self, to, rid), currentrow(0), fieldmap(NULL)
        {
                /* A number of affected rows from from mysql_affected_rows.
                 */
@@ -144,7 +145,7 @@ class MySQLresult : public SQLresult
                }
        }
 
-       MySQLresult(Module* self, Module* to, SQLerror e, unsigned int id) : SQLresult(self, to, id), currentrow(0)
+       MySQLresult(Module* self, Module* to, SQLerror e, unsigned int rid) : SQLresult(self, to, rid), currentrow(0)
        {
                rows = 0;
                error = e;
@@ -511,7 +512,7 @@ void ClearOldConnections(ConfigReader* conf)
        {
                if (!HostInConf(conf, i->second->GetConfHost()))
                {
-                       DELETE(i->second);
+                       delete i->second;
                        safei = i;
                        --i;
                        Connections.erase(safei);
@@ -525,7 +526,7 @@ void ClearAllConnections()
        while ((i = Connections.begin()) != Connections.end())
        {
                Connections.erase(i);
-               DELETE(i->second);
+               delete i->second;
        }
 }
 
@@ -624,7 +625,7 @@ void* DispatcherThread(void* arg);
 
 /** Used by m_mysql to notify one thread when the other has a result
  */
-class Notifier : public InspSocket
+class Notifier : public BufferedSocket
 {
        insp_sockaddr sock_us;
        socklen_t uslen;
@@ -634,9 +635,9 @@ class Notifier : public InspSocket
 
        /* Create a socket on a random port. Let the tcp stack allocate us an available port */
 #ifdef IPV6
-       Notifier(InspIRCd* SI) : InspSocket(SI, "::1", 0, true, 3000)
+       Notifier(InspIRCd* SI) : BufferedSocket(SI, "::1", 0, true, 3000)
 #else
-       Notifier(InspIRCd* SI) : InspSocket(SI, "127.0.0.1", 0, true, 3000)
+       Notifier(InspIRCd* SI) : BufferedSocket(SI, "127.0.0.1", 0, true, 3000)
 #endif
        {
                uslen = sizeof(sock_us);
@@ -646,7 +647,7 @@ class Notifier : public InspSocket
                }
        }
 
-       Notifier(InspIRCd* SI, int newfd, char* ip) : InspSocket(SI, newfd, ip)
+       Notifier(InspIRCd* SI, int newfd, char* ip) : BufferedSocket(SI, newfd, ip)
        {
        }
 
@@ -738,6 +739,8 @@ class ModuleSQL : public Module
                }
 
                ServerInstance->Modules->PublishInterface("SQL", this);
+               Implementation eventlist[] = { I_OnRehash, I_OnRequest };
+               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
        virtual ~ModuleSQL()
@@ -751,10 +754,6 @@ class ModuleSQL : public Module
        }
 
 
-       void Implements(char* List)
-       {
-               List[I_OnRehash] = List[I_OnRequest] = 1;
-       }
 
        unsigned long NewID()
        {
@@ -763,7 +762,7 @@ class ModuleSQL : public Module
                return ++currid;
        }
 
-       char* OnRequest(Request* request)
+       virtual const char* OnRequest(Request* request)
        {
                if(strcmp(SQLREQID, request->GetId()) == 0)
                {
@@ -879,10 +878,10 @@ void* DispatcherThread(void* arg)
                        /* XXX: Unlock */
                }
 
-               usleep(50);
+               usleep(1000);
        }
 
        return NULL;
 }
 
-MODULE_INIT(ModuleSQL);
+MODULE_INIT(ModuleSQL)