I have an application that uses Event to organize a lot of
separate UDP query/response transactions with many different servers.

So far so good.  Event is the right tool for the job and it's working
very nicely.

BUT - I sometimes have to call gethostbyname from inside a callback.
This can block for a couple of seconds, which stalls all the other
Event processing -- UDP packets pile up, kernel buffers fill, and
chaos generally ensues.

The blocking nature of gethosbyname is well-known and solutions are
well-understood.  The 'standard' solution (employed by netscape and
squid among others) is to fork one or more 'helper' processes.  The
helper calls gethostbyname and the main app communicates with it
through a socket or pipe, so the main app can do other things while
the helper works.

Another solution might be to send a query to a resolver directly and
trigger an io Event upon recipt of a reply.  Net::DNS comes to mind.
This would fit neatly into the structure I already have, i.e.,
organize the interaction with the nameserver via Events.

My questions:  
- has anyone done this already?  Someone else must have
encountered this problem before.  Are there pre-existing solutions?

Thanks,
John Salmon

Reply via email to