[Dnsmasq-discuss] Patch: Add --ping-timeout option

Aaron Opfer aopfer at bennett-electric.com
Mon May 21 16:56:44 BST 2012

I've been thinking about this. It's clear to me that the only way to
correctly implement my patch would be to restructure dnsmasq so that it
waits for a ping response asynchronously. This, of course, would also
have the added benefit of making the DHCP server capable of servicing
more than one DHCP request at once while performing the pings, if done
right. This would be a huge undertaking though, from the looks of it,
as we'd have to pull apart several functions to do it, shove those into
select calls, and so on.

I don't know if I'm willing to do all that just for my one-off request.
My patched dnsmasq works for the most part, but obviously not down to
millisecond precision like I initially believed. Maybe the patch would
still be salvagable if we used clock_gettime() on Linux (and fallback
on dnsmasq_time*1000 for other platforms) for calculating the time

Alternatively, we could make the --ping-timeout option in units of
250ms of time, and then just make dnsmasq loop that many times around.

So instead of:

> start = time();

> while (time() - start < PING_WAIT)
> {
> send_ping();
> wait_250ms_for_a_reply()
> }

We'd have something like:

> i = ping_timeout;
> while (i--)
> {
> send_ping();
> wait_250ms_for_a_reply();
> }

And of course, another alternative is to do nothing at all. :-)

Aaron Opfer

More information about the Dnsmasq-discuss mailing list