]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_mysql.cpp
Don't call events provided by dying or dead modules.
[user/henk/code/inspircd.git] / src / modules / extra / m_mysql.cpp
index d94c75917b548fbe7176a95d2c96817f4f9b5626..377ffee7e026e10553a93da519fdc7a79828c30f 100644 (file)
@@ -1,10 +1,17 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
+ *   Copyright (C) 2015 Daniel Vassdal <shutter@canternet.org>
+ *   Copyright (C) 2014, 2016 Adam <Adam@anope.org>
+ *   Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2016-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2006-2007, 2009 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2006-2009 Craig Edwards <craigedwards@brainbox.cc>
- *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
+ *   Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2005, 2008-2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -66,7 +73,7 @@
  * worker thread wakes up, and checks if there is a request at the head of its queue.
  * If there is, it processes this request, blocking the worker thread but leaving the ircd
  * thread to go about its business as usual. During this period, the ircd thread is able
- * to insert futher pending requests into the queue.
+ * to insert further pending requests into the queue.
  *
  * Once the processing of a request is complete, it is removed from the incoming queue to
  * an outgoing queue, and initialized as a 'response'. The worker thread then signals the
@@ -83,7 +90,7 @@
  * one the module was originally instantiated upon, there is a chance of all hell breaking loose
  * if a module is ever put in a re-enterant state (stack corruption could occur, crashes, data
  * corruption, and worse, so DONT think about it until the day comes when InspIRCd is 100%
- * gauranteed threadsafe!)
+ * guaranteed threadsafe!)
  */
 
 class SQLConnection;
@@ -168,7 +175,10 @@ class MySQLresult : public SQL::Result
        std::vector<std::string> colnames;
        std::vector<SQL::Row> fieldlists;
 
-       MySQLresult(MYSQL_RES* res, int affected_rows) : err(SQL::SUCCESS), currentrow(0), rows(0)
+       MySQLresult(MYSQL_RES* res, int affected_rows)
+               : err(SQL::SUCCESS)
+               , currentrow(0)
+               , rows(0)
        {
                if (affected_rows >= 1)
                {
@@ -211,7 +221,10 @@ class MySQLresult : public SQL::Result
                }
        }
 
-       MySQLresult(SQL::Error& e) : err(e)
+       MySQLresult(SQL::Error& e)
+               : err(e)
+               , currentrow(0)
+               , rows(0)
        {
 
        }
@@ -308,7 +321,7 @@ class SQLConnection : public SQL::Provider
 
        ~SQLConnection()
        {
-               Close();
+               mysql_close(connection);
        }
 
        // This method connects to the database using the credentials supplied to the constructor, and returns
@@ -366,7 +379,7 @@ class SQLConnection : public SQL::Provider
                /* Parse the command string and dispatch it to mysql */
                if (CheckConnection() && !mysql_real_query(connection, query.data(), query.length()))
                {
-                       /* Successfull query */
+                       /* Successful query */
                        MYSQL_RES* res = mysql_use_result(connection);
                        unsigned long rows = mysql_affected_rows(connection);
                        return new MySQLresult(res, rows);
@@ -387,11 +400,6 @@ class SQLConnection : public SQL::Provider
                return true;
        }
 
-       void Close()
-       {
-               mysql_close(connection);
-       }
-
        void Submit(SQL::Query* q, const std::string& qs) CXX11_OVERRIDE
        {
                ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Executing MySQL query: " + qs);
@@ -439,8 +447,8 @@ class SQLConnection : public SQL::Provider
 };
 
 ModuleSQL::ModuleSQL()
+       : Dispatcher(NULL)
 {
-       Dispatcher = NULL;
 }
 
 void ModuleSQL::init()
@@ -548,7 +556,7 @@ void ModuleSQL::OnUnloadModule(Module* mod)
 
 Version ModuleSQL::GetVersion()
 {
-       return Version("Provides MySQL support", VF_VENDOR);
+       return Version("Provides the ability for SQL modules to query a MySQL database.", VF_VENDOR);
 }
 
 void DispatcherThread::Run()