From 2329d59b09cdc05b0b403f7d313df65492e1813b Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 8 Aug 2006 09:32:57 +0000 Subject: Extra checking that the fd's we pass to SocketEngine::AddFd were added (a lot of assuming was going off, leading to total chaos if we run out of fd's etc) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4780 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/dns.cpp') 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; + } + } } } } -- cgit v1.3.1-10-gc9f91