-
- virtual void OnAcceptReady(const std::string &ipconnectedto, int nfd, const std::string &incomingip)
- {
- // XXX unsafe casts suck
- new Notifier(this->Parent, this->ServerInstance, nfd, (char *)ipconnectedto.c_str());
- }
-
- /* Using getsockname and ntohs, we can determine which port number we were allocated */
- int GetPort()
- {
-#ifdef IPV6
- return ntohs(sock_us.sin6_port);
-#else
- return ntohs(sock_us.sin_port);
-#endif
- }
-};
-
-ModuleSQL::ModuleSQL(InspIRCd* Me) : Module(Me), rehashing(false)
-{
- ServerInstance->Modules->UseInterface("SQLutils");
-
- Conf = new ConfigReader(ServerInstance);
- PublicServerInstance = ServerInstance;
- currid = 0;
-
- /* Create a socket on a random port. Let the tcp stack allocate us an available port */
-#ifdef IPV6
- MessagePipe = new MySQLListener(this, ServerInstance, 0, "::1");
-#else
- MessagePipe = new MySQLListener(this, ServerInstance, 0, "127.0.0.1");
-#endif
-
- LoggingMutex = ServerInstance->Mutexes->CreateMutex();
- ConnMutex = ServerInstance->Mutexes->CreateMutex();
-
- if (MessagePipe->GetFd() == -1)
- {
- delete ConnMutex;
- ServerInstance->Modules->DoneWithInterface("SQLutils");
- throw ModuleException("m_mysql: unable to create ITC pipe");
- }
- else
- {
- LoggingMutex->Lock();
- ServerInstance->Logs->Log("m_mysql", DEBUG, "MySQL: Interthread comms port is %d", MessagePipe->GetPort());
- LoggingMutex->Unlock();
- }
-
- Dispatcher = new DispatcherThread(ServerInstance, this);
- ServerInstance->Threads->Start(Dispatcher);
-
- ResultsMutex = ServerInstance->Mutexes->CreateMutex();
- QueueMutex = ServerInstance->Mutexes->CreateMutex();
-
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- /* Tell worker thread to exit NOW,
- * Automatically joins */
- delete Dispatcher;
- delete LoggingMutex;
- delete ResultsMutex;
- delete QueueMutex;
- delete ConnMutex;
- ServerInstance->Modules->DoneWithInterface("SQLutils");
- throw ModuleException("m_mysql: Unable to publish feature 'SQL'");
- }
-
- ServerInstance->Modules->PublishInterface("SQL", this);
- Implementation eventlist[] = { I_OnRehash, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);