this->cache[r.question] = r;
}
+ void Close()
+ {
+ // Shutdown the socket if it exists.
+ if (HasFd())
+ {
+ SocketEngine::Shutdown(this, 2);
+ SocketEngine::Close(this);
+ }
+
+ // Remove all entries from the cache.
+ cache.clear();
+ }
+
public:
DNS::Request* requests[MAX_REQUEST_ID+1];
~MyManager()
{
// Ensure Process() will fail for new requests
+ Close();
unloading = true;
for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i)
void Rehash(const std::string& dnsserver, std::string sourceaddr, unsigned int sourceport)
{
- if (this->HasFd())
- {
- SocketEngine::Shutdown(this, 2);
- SocketEngine::Close(this);
-
- // Remove all entries from the cache.
- cache.clear();
- }
-
irc::sockets::aptosa(dnsserver, DNS::PORT, myserver);
/* Initialize mastersocket */
+ Close();
int s = socket(myserver.family(), SOCK_DGRAM, 0);
this->SetFd(s);
/* Have we got a socket? */
- if (this->GetFd() != -1)
+ if (this->HasFd())
{
SocketEngine::SetReuse(s);
SocketEngine::NonBlocking(s);