+ private:
+ ModuleSQL* Parent;
+ InspIRCd* ServerInstance;
+ public:
+ DispatcherThread(InspIRCd* Instance, ModuleSQL* CreatorModule) : Thread(), Parent(CreatorModule), ServerInstance(Instance) { }
+ ~DispatcherThread() { }
+ virtual void Run();
+};
+
+/** Used by m_mysql to notify one thread when the other has a result
+ */
+class Notifier : public BufferedSocket
+{
+ ModuleSQL* Parent;
+
+ public:
+ Notifier(ModuleSQL* P, InspIRCd* SI, int newfd, char* ip) : BufferedSocket(SI, newfd, ip), Parent(P) { }
+
+ virtual bool OnDataReady()
+ {
+ char data = 0;
+ /* NOTE: Only a single character is read so we know we
+ * cant get a partial read. (We've been told that theres
+ * data waiting, so we wont ever get EAGAIN)
+ * The function GetCharId translates a single character
+ * back into an iterator.
+ */
+
+ if (Instance->SE->Recv(this, &data, 1, 0) > 0)
+ {
+ Parent->ConnMutex->Lock();
+ ConnMap::iterator iter = GetCharId(data);
+ if (iter != Connections.end())
+ {
+ /* Lock the mutex, send back the data */
+ Parent->ResultsMutex->Lock();
+ ResultQueue::iterator n = iter->second->rq.begin();
+ (*n)->Send();
+ delete (*n);
+ iter->second->rq.pop_front();
+ Parent->ResultsMutex->Unlock();
+ Parent->ConnMutex->Unlock();
+ return true;
+ }
+ /* No error, but unknown id */
+ Parent->ConnMutex->Unlock();
+ return true;
+ }
+
+ /* Erk, error on descriptor! */
+ return false;
+ }
+};
+
+/** Spawn sockets from a listener
+ */
+class MySQLListener : public ListenSocketBase
+{
+ ModuleSQL* Parent;