summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 0436095b6..cbe56337d 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -202,6 +202,10 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
/* Add a query with a predefined header, and allocate an ID for it. */
DNSRequest* DNS::AddQuery(DNSHeader *header, int &id)
{
+ /* Is the DNS connection down? */
+ if (MasterSocket == -1)
+ return NULL;
+
/* Are there already the max number of requests on the go? */
if (requests.size() == DNS::MAX_REQUEST_ID + 1)
return NULL;
@@ -323,7 +327,15 @@ DNS::DNS()
log(DEBUG,"Add master socket %d",MasterSocket);
/* Hook the descriptor into the socket engine */
if (ServerInstance && ServerInstance->SE)
- ServerInstance->SE->AddFd(MasterSocket,true,X_ESTAB_DNS);
+ {
+ if (!ServerInstance->SE->AddFd(MasterSocket,true,X_ESTAB_DNS))
+ {
+ log(DEFAULT,"Internal error starting DNS - hostnames will NOT resolve.");
+ shutdown(MasterSocket,2);
+ close(MasterSocket);
+ MasterSocket = -1;
+ }
+ }
}
}
}