summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-11 20:15:21 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-11 20:15:21 +0000
commit4cfe4cbc62dfca59dba74f0e6811fd09e31609df (patch)
tree71d6ad60cf1475e8f8ddfd65ca276ce5c0d5df67
parent8bc6254a5912f544c99623f0473d6f025f61b7b9 (diff)
Hmm
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8579 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/dns.cpp16
-rw-r--r--src/modules/m_http_client.cpp30
-rw-r--r--src/socketengines/socketengine_epoll.cpp4
3 files changed, 29 insertions, 21 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 53224ba86..8a274577e 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -213,6 +213,8 @@ inline void DNS::EmptyHeader(unsigned char *output, const DNSHeader *header, con
/** Send requests we have previously built down the UDP socket */
int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryType qt)
{
+ ServerInstance->Log(DEBUG,"DNSRequest::SendRequests");
+
unsigned char payload[sizeof(DNSHeader)];
this->rr_class = 1;
@@ -242,6 +244,8 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
if (ServerInstance->SE->SendTo(dnsobj, (const char*)payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
return -1;
}
+
+ ServerInstance->Log(DEBUG,"Sent OK");
return 0;
}
@@ -362,6 +366,7 @@ void DNS::Rehash()
if (!ServerInstance->BindSocket(this->GetFd(), portpass, "", false))
{
/* Failed to bind */
+ ServerInstance->Log(DEBUG,"Error binding dns socket");
ServerInstance->SE->Shutdown(this, 2);
ServerInstance->SE->Close(this);
this->SetFd(-1);
@@ -382,11 +387,16 @@ void DNS::Rehash()
}
}
}
+ else
+ {
+ ServerInstance->Log(DEBUG,"Error creating dns socket");
+ }
}
/** Initialise the DNS UDP socket so that we can send requests */
DNS::DNS(InspIRCd* Instance) : ServerInstance(Instance)
{
+ ServerInstance->Log(DEBUG,"DNS::DNS");
/* Clear the Resolver class table */
memset(Classes,0,sizeof(Classes));
@@ -949,6 +959,7 @@ void Resolver::TriggerCachedResult()
/** High level abstraction of dns used by application at large */
Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt, bool &cached, Module* creator) : ServerInstance(Instance), Creator(creator), input(source), querytype(qt)
{
+ ServerInstance->Log(DEBUG,"Resolver::Resolver");
cached = false;
CQ = ServerInstance->Res->GetCache(source);
@@ -1017,6 +1028,10 @@ Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt,
/* We shouldnt get here really */
return;
}
+ else
+ {
+ ServerInstance->Log(DEBUG,"DNS request id %d", this->myid);
+ }
}
/** Called when an error occurs */
@@ -1103,6 +1118,7 @@ void DNS::HandleEvent(EventType, int)
/** Add a derived Resolver to the working set */
bool DNS::AddResolverClass(Resolver* r)
{
+ ServerInstance->Log(DEBUG,"AddResolverClass %08lx", r);
/* Check the pointers validity and the id's validity */
if ((r) && (r->GetId() > -1))
{
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index d7722caff..62dfe6831 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -51,16 +51,20 @@ class HTTPResolver : public Resolver
{
private:
HTTPSocket *socket;
+ std::string orig;
public:
HTTPResolver(HTTPSocket *socket, InspIRCd *Instance, const string &hostname, bool &cached, Module* me) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), socket(socket)
{
ServerInstance->Log(DEBUG,"HTTPResolver::HTTPResolver");
+ orig = hostname;
}
void OnLookupComplete(const string &result, unsigned int ttl, bool cached, int resultnum = 0)
{
if (!resultnum)
socket->Connect(result);
+ else
+ socket->Connect(orig);
}
void OnError(ResolverError e, const string &errmsg)
@@ -146,23 +150,10 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
this->port = url.port;
strlcpy(this->host, url.domain.c_str(), MAXBUF);
- in_addr addy1;
-#ifdef IPV6
- in6_addr addy2;
- if ((inet_aton(this->host, &addy1) > 0) || (inet_pton(AF_INET6, this->host, &addy2) > 0))
-#else
- if (inet_aton(this->host, &addy1) > 0)
-#endif
- {
- bool cached;
- HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
- Instance->AddResolver(r, cached);
- return true;
- }
- else
- {
- this->Connect(url.domain);
- }
+ bool cached;
+ HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
+ Instance->AddResolver(r, cached);
+ return true;
return true;
}
@@ -288,11 +279,8 @@ bool HTTPSocket::OnDataReady()
Instance->Log(DEBUG,"HTTPSocket::OnDataReady()");
char *data = this->Read();
- if (!data)
- {
- this->Close();
+ if (!data || !*data)
return false;
- }
if (this->status < HTTP_DATA)
{
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp
index 9da569b8f..89b1ea1ef 100644
--- a/src/socketengines/socketengine_epoll.cpp
+++ b/src/socketengines/socketengine_epoll.cpp
@@ -38,6 +38,7 @@ EPollEngine::~EPollEngine()
bool EPollEngine::AddFd(EventHandler* eh)
{
+ ServerInstance->Log(DEBUG,"Add new fd: %d", eh->GetFd());
int fd = eh->GetFd();
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
{
@@ -120,6 +121,9 @@ int EPollEngine::DispatchEvents()
socklen_t codesize;
int errcode;
int i = epoll_wait(EngineHandle, events, MAX_DESCRIPTORS, 1000);
+
+ ServerInstance->Log(DEBUG,"DispatchEvents num events = %d of %d", i, CurrentSetSize);
+
for (int j = 0; j < i; j++)
{
if (events[j].events & EPOLLHUP)