2010-02-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Call ares_process_fd() each time after epoll to handle timeout.
	* src/EpollEventPoll.cc
	* src/EpollEventPoll.h
pull/1/head
Tatsuhiro Tsujikawa 2010-02-01 15:21:41 +00:00
parent ace04f4c80
commit 3f7df00d98
3 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2010-02-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Call ares_process_fd() each time after epoll to handle timeout.
* src/EpollEventPoll.cc
* src/EpollEventPoll.h
2010-01-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Suppressed type-cast compiler warning

View File

@ -292,6 +292,11 @@ void EpollEventPoll::AsyncNameResolverEntry::removeSocketEvents
}
}
void EpollEventPoll::AsyncNameResolverEntry::processTimeout()
{
_nameResolver->process(ARES_SOCKET_BAD, ARES_SOCKET_BAD);
}
#endif // ENABLE_ASYNC_DNS
EpollEventPoll::EpollEventPoll():_logger(LogFactory::getInstance())
@ -336,6 +341,19 @@ void EpollEventPoll::poll(const struct timeval& tv)
}
}
#ifdef ENABLE_ASYNC_DNS
// It turns out that we have to call ares_process_fd before ares's
// own timeout and ares may create new sockets or closes socket in
// their API. So we call ares_process_fd for all ares_channel and
// re-register their sockets.
for(std::deque<SharedHandle<AsyncNameResolverEntry> >::iterator i =
_nameResolverEntries.begin(); i != _nameResolverEntries.end(); ++i) {
(*i)->processTimeout();
(*i)->removeSocketEvents(this);
(*i)->addSocketEvents(this);
}
#endif // ENABLE_ASYNC_DNS
// TODO timeout of name resolver is determined in Command(AbstractCommand,
// DHTEntryPoint...Command)
}

View File

@ -216,6 +216,10 @@ private:
void addSocketEvents(EpollEventPoll* socketPoll);
void removeSocketEvents(EpollEventPoll* socketPoll);
// Calls AsyncNameResolver::process(ARES_SOCKET_BAD,
// ARES_SOCKET_BAD).
void processTimeout();
};
#endif // ENABLE_ASYNC_DNS