-/** Spawn HTTP sockets from a listener
- */
-class MySQLListener : public ListenSocketBase
-{
- FileReader* index;
-
- public:
- HttpListener(InspIRCd* Instance, int port, char* addr) : ListenSocketBase(Instance, port, addr)
- {
- this->index = idx;
- }
-
- virtual void OnAcceptReady(const std::string &ipconnectedto, int nfd, const std::string &incomingip)
- {
- new Notifier(this->ServerInstance, nfd, (char)ipconnectedto.c_str()); // XXX unsafe casts suck
- }
-};
-
-/** Used by m_mysql to notify one thread when the other has a result
- */
-class Notifier : public BufferedSocket
-{
- insp_sockaddr sock_us;
- socklen_t uslen;
- ModuleSQL* Parent;
-
- public:
- Notifier(InspIRCd* SI, int newfd, char* ip) : BufferedSocket(SI, newfd, ip) { }
-
- /* 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
- }
-
- 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)
- {
- 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();
- return true;
- }
- /* No error, but unknown id */
- return true;
- }
-
- /* Erk, error on descriptor! */
- return false;
- }
-};
-
-