diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 09:32:57 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 09:32:57 +0000 |
commit | 2329d59b09cdc05b0b403f7d313df65492e1813b (patch) | |
tree | 6d5f005565b62883e09ed2b2e09752fc034da413 /src/dns.cpp | |
parent | 3794888ebf1fb19f404c22ff2d5333ccc6c3129e (diff) |
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
Diffstat (limited to 'src/dns.cpp')
-rw-r--r-- | src/dns.cpp | 14 |
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; + } + } } } } |