-
- return NULL;
- }
-
- virtual void OnRehash(userrec* user, const std::string ¶meter)
- {
- rehashing = true;
- }
-
- virtual Version GetVersion()
- {
- return Version(1,1,0,0,VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
- }
-
-};
-
-void* DispatcherThread(void* arg)
-{
- ModuleSQL* thismodule = (ModuleSQL*)arg;
- LoadDatabases(thismodule->Conf, thismodule->PublicServerInstance);
-
- /* Connect back to the Notifier */
-
- if ((QueueFD = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1)
- {
- /* crap, we're out of sockets... */
- return NULL;
- }
-
- insp_sockaddr addr;
-
-#ifdef IPV6
- insp_aton("::1", &addr.sin6_addr);
- addr.sin6_family = AF_FAMILY;
- addr.sin6_port = htons(MessagePipe->GetPort());
-#else
- insp_inaddr ia;
- insp_aton("127.0.0.1", &ia);
- addr.sin_family = AF_FAMILY;
- addr.sin_addr = ia;
- addr.sin_port = htons(MessagePipe->GetPort());
-#endif
-
- if (connect(QueueFD, (sockaddr*)&addr,sizeof(addr)) == -1)
- {
- /* wtf, we cant connect to it, but we just created it! */
- return NULL;
- }
-
- while (!giveup)
- {
- if (thismodule->rehashing)
- {
- /* XXX: Lock */
- pthread_mutex_lock(&queue_mutex);
- thismodule->rehashing = false;
- LoadDatabases(thismodule->Conf, thismodule->PublicServerInstance);
- pthread_mutex_unlock(&queue_mutex);
- /* XXX: Unlock */
- }
-
- SQLConnection* conn = NULL;
- /* XXX: Lock here for safety */
- pthread_mutex_lock(&queue_mutex);
- for (ConnMap::iterator i = Connections.begin(); i != Connections.end(); i++)
- {
- if (i->second->queue.totalsize())
- {
- conn = i->second;
- break;
- }
- }
- pthread_mutex_unlock(&queue_mutex);
- /* XXX: Unlock */
-
- /* Theres an item! */
- if (conn)