X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_mysql.cpp;h=c63ebe7e9d3618589f7835ca75a14ca895b708db;hb=d3c7457dda8555e410f4fbc36bb1b1b4cb0ae3f2;hp=862dde8117765e03f91cc80735cc664baca47585;hpb=ae7c3cf06646e18a9cbe4bf63d4c993606698326;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 862dde811..c63ebe7e9 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -11,14 +11,12 @@ * --------------------------------------------------- */ -#include -#include +#include "inspircd.h" #include #include #include "users.h" #include "channels.h" #include "modules.h" -#include "inspircd.h" #include "m_sqlv2.h" /* VERSION 2 API: With nonblocking (threaded) requests */ @@ -626,7 +624,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; @@ -636,9 +634,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); @@ -648,7 +646,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) { } @@ -678,7 +676,7 @@ class Notifier : public InspSocket * The function GetCharId translates a single character * back into an iterator. */ - if (read(this->GetFd(), &data, 1) > 0) + if (Instance->SE->Recv(this, &data, 1, 0) > 0) { ConnMap::iterator iter = GetCharId(data); if (iter != Connections.end()) @@ -715,7 +713,7 @@ class ModuleSQL : public Module ModuleSQL(InspIRCd* Me) : Module::Module(Me), rehashing(false) { - ServerInstance->UseInterface("SQLutils"); + ServerInstance->Modules->UseInterface("SQLutils"); Conf = new ConfigReader(ServerInstance); PublicServerInstance = ServerInstance; @@ -732,24 +730,24 @@ class ModuleSQL : public Module throw ModuleException("m_mysql: Failed to create dispatcher thread: " + std::string(strerror(errno))); } - if (!ServerInstance->PublishFeature("SQL", this)) + if (!ServerInstance->Modules->PublishFeature("SQL", this)) { /* Tell worker thread to exit NOW */ giveup = true; throw ModuleException("m_mysql: Unable to publish feature 'SQL'"); } - ServerInstance->PublishInterface("SQL", this); + ServerInstance->Modules->PublishInterface("SQL", this); } virtual ~ModuleSQL() { giveup = true; ClearAllConnections(); - DELETE(Conf); - ServerInstance->UnpublishInterface("SQL", this); - ServerInstance->UnpublishFeature("SQL"); - ServerInstance->DoneWithInterface("SQLutils"); + delete Conf; + ServerInstance->Modules->UnpublishInterface("SQL", this); + ServerInstance->Modules->UnpublishFeature("SQL"); + ServerInstance->Modules->DoneWithInterface("SQLutils"); } @@ -798,7 +796,7 @@ class ModuleSQL : public Module return NULL; } - virtual void OnRehash(userrec* user, const std::string ¶meter) + virtual void OnRehash(User* user, const std::string ¶meter) { rehashing = true; } @@ -887,29 +885,4 @@ void* DispatcherThread(void* arg) return NULL; } - -// stuff down here is the module-factory stuff. For basic modules you can ignore this. - -class ModuleSQLFactory : public ModuleFactory -{ - public: - ModuleSQLFactory() - { - } - - ~ModuleSQLFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleSQL(Me); - } - -}; - - -extern "C" void * init_module( void ) -{ - return new ModuleSQLFactory; -} +MODULE_INIT(ModuleSQL)