- public:
-
- ConfigReader *Conf;
- InspIRCd* PublicServerInstance;
- pthread_t Dispatcher;
- int currid;
- bool rehashing;
-
- ModuleSQL(InspIRCd* Me)
- : Module::Module(Me), rehashing(false)
- {
- ServerInstance->Modules->UseInterface("SQLutils");
-
- Conf = new ConfigReader(ServerInstance);
- PublicServerInstance = ServerInstance;
- currid = 0;
- SQLModule = this;
-
- MessagePipe = new Notifier(ServerInstance);
-
- pthread_attr_t attribs;
- pthread_attr_init(&attribs);
- pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&this->Dispatcher, &attribs, DispatcherThread, (void *)this) != 0)
- {
- throw ModuleException("m_mysql: Failed to create dispatcher thread: " + std::string(strerror(errno)));
- }
-
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- /* Tell worker thread to exit NOW */
- giveup = true;
- 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);
- }
-
- virtual ~ModuleSQL()
- {
- giveup = true;
- ClearAllConnections();
- delete Conf;
- ServerInstance->Modules->UnpublishInterface("SQL", this);
- ServerInstance->Modules->UnpublishFeature("SQL");
- ServerInstance->Modules->DoneWithInterface("SQLutils");
- }
-
-
-
- unsigned long NewID()
- {
- if (currid+1 == 0)
- currid++;
- return ++currid;
- }