mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-12 03:59:03 -04:00
*EXPERIMENTAL* Tied DNS into new socket engine
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2331 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
b81c2e4c4e
commit
280f52aeae
15
src/dns.cpp
15
src/dns.cpp
@ -37,6 +37,9 @@ using namespace std;
|
||||
#include <arpa/inet.h>
|
||||
#include "dns.h"
|
||||
#include "helperfuncs.h"
|
||||
#include "socketengine.h"
|
||||
|
||||
extern SocketEngine* SE;
|
||||
|
||||
extern int statsAccept,statsRefused,statsUnknown,statsCollisions,statsDns,statsDnsGood,statsDnsBad,statsConnects,statsSent,statsRecv;
|
||||
|
||||
@ -664,6 +667,9 @@ bool DNS::ReverseLookup(std::string ip)
|
||||
return false;
|
||||
}
|
||||
log(DEBUG,"DNS: ReverseLookup, fd=%d",this->myfd);
|
||||
#ifndef THREADED_DNS
|
||||
SE->AddFd(this->myfd,true,X_ESTAB_DNS);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -676,6 +682,9 @@ bool DNS::ForwardLookup(std::string host)
|
||||
return false;
|
||||
}
|
||||
log(DEBUG,"DNS: ForwardLookup, fd=%d",this->myfd);
|
||||
#ifndef THREADED_DNS
|
||||
SE->AddFd(this->myfd,true,X_ESTAB_DNS);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -699,6 +708,9 @@ std::string DNS::GetResult()
|
||||
{
|
||||
log(DEBUG,"DNS: GetResult()");
|
||||
result = dns_getresult(this->myfd);
|
||||
#ifndef THREADED_DNS
|
||||
SE->DelFd(this->myfd);
|
||||
#endif
|
||||
if (result) {
|
||||
statsDnsGood++;
|
||||
dns_close(this->myfd);
|
||||
@ -720,6 +732,9 @@ std::string DNS::GetResultIP()
|
||||
result = dns_getresult(this->myfd);
|
||||
if (this->myfd != -1)
|
||||
{
|
||||
#ifndef THREADED_DNS
|
||||
SE->DelFd(this->myfd);
|
||||
#endif
|
||||
dns_close(this->myfd);
|
||||
}
|
||||
if (result)
|
||||
|
@ -60,6 +60,9 @@ using namespace std;
|
||||
#include "dns.h"
|
||||
#include "helperfuncs.h"
|
||||
#include "hashcomp.h"
|
||||
#include "socketengine.h"
|
||||
|
||||
extern SocketEngine* SE;
|
||||
|
||||
extern int MaxWhoResults;
|
||||
|
||||
|
@ -2656,10 +2656,6 @@ int InspIRCd(char** argv, int argc)
|
||||
OLDTIME = TIME;
|
||||
TIME = time(NULL);
|
||||
|
||||
#ifndef THREADED_DNS
|
||||
dns_poll();
|
||||
#endif
|
||||
|
||||
// *FIX* Instead of closing sockets in kill_link when they receive the ERROR :blah line, we should queue
|
||||
// them in a list, then reap the list every second or so.
|
||||
if (((TIME % 5) == 0) && (!expire_run))
|
||||
@ -2713,6 +2709,9 @@ int InspIRCd(char** argv, int argc)
|
||||
else if (SE->GetType(activefds[activefd]) == X_ESTAB_DNS)
|
||||
{
|
||||
log(DEBUG,"Got a ready socket of type X_ESTAB_DNS");
|
||||
#ifndef THREADED_DNS
|
||||
dns_poll();
|
||||
#endif
|
||||
}
|
||||
else if (SE->GetType(activefds[activefd]) == X_LISTEN)
|
||||
{
|
||||
|
@ -40,12 +40,16 @@ SocketEngine::~SocketEngine()
|
||||
|
||||
char SocketEngine::GetType(int fd)
|
||||
{
|
||||
if ((fd < 0) || (fd > 65535))
|
||||
return X_EMPTY_SLOT;
|
||||
/* Mask off the top bit used for 'read/write' state */
|
||||
return (ref[fd] & ~0x80);
|
||||
}
|
||||
|
||||
bool SocketEngine::AddFd(int fd, bool readable, char type)
|
||||
{
|
||||
if ((fd < 0) || (fd > 65535))
|
||||
return false;
|
||||
this->fds.push_back(fd);
|
||||
ref[fd] = type;
|
||||
if (readable)
|
||||
@ -79,6 +83,10 @@ return true;
|
||||
bool SocketEngine::DelFd(int fd)
|
||||
{
|
||||
log(DEBUG,"SocketEngine::DelFd(%d)",fd);
|
||||
|
||||
if ((fd < 0) || (fd > 65535))
|
||||
return false;
|
||||
|
||||
bool found = false;
|
||||
for (std::vector<int>::iterator i = fds.begin(); i != fds.end(); i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user