Add new features to IOSource::Manager, used by DNS_Mgr

- iosource_mgr can now track write events to file descriptors as well
  as read events. This adds an argument to both RegisterFd() and
  UnregisterFd() for setting the mode, defaulting to read.
- IOSources can now implement a ProcessFd() method that allows them to
  handle events to single file descriptors instead of of having to
  loop through/track sets of them at processing time.
This commit is contained in:
Tim Wojtulewicz 2022-04-05 21:14:04 -07:00
parent c2bf602d94
commit f9f37b11c6
6 changed files with 179 additions and 63 deletions

View file

@ -283,7 +283,7 @@ void run_loop()
{
util::detail::set_processing_status("RUNNING", "run_loop");
std::vector<iosource::IOSource*> ready;
iosource::Manager::ReadySources ready;
ready.reserve(iosource_mgr->TotalSize());
while ( iosource_mgr->Size() || (BifConst::exit_only_after_terminate && ! terminating) )
@ -310,11 +310,16 @@ void run_loop()
if ( ! ready.empty() )
{
for ( auto src : ready )
for ( const auto& src : ready )
{
DBG_LOG(DBG_MAINLOOP, "processing source %s", src->Tag());
current_iosrc = src;
src->Process();
auto* iosrc = src.src;
DBG_LOG(DBG_MAINLOOP, "processing source %s", iosrc->Tag());
current_iosrc = iosrc;
if ( iosrc->ImplementsProcessFd() && src.fd != -1 )
iosrc->ProcessFd(src.fd, src.flags);
else
iosrc->Process();
}
}
else if ( (have_pending_timers || communication_enabled ||