<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 16, 2015 at 7:24 PM, Simon Kelley <span dir="ltr"><<a href="mailto:simon@thekelleys.org.uk" target="_blank">simon@thekelleys.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">Here's one possible solution.<br>
<br>
dhcp-hostfile can take a directory instead of a filename, so instead<br>
of having one  file with 40k lines in it, have a directory with a file<br>
for each host. (Aside, 40k files is a big directory, but it can be<br>
split into multiple directories, if needed). By itself, this will go<br>
backwards, since opening 40k small files to read them all will be even<br>
slower, so we need an addition to dnsmasq.<br></div></blockquote><div><br></div><div>Yeah, this could resolve the incomplete config file issue. But the slower issue is also bad.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">
<br>
The addition to dnsmasq is to use inotify to detect when a file is<br>
added or written. The development branch of dnsmasq already has code<br>
to do this for resolv files. With this change, there's no need to us a<br>
signal, and no need to re-read all the files. When a file appears in<br>
the directory or is modified _and_is_closed_ dnsmasq will wake up and<br>
read just that file. Much better, this fixes the race condition too.<br></div></blockquote><div><br></div><div>It is very impressive!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="overflow:hidden">
<br>
The simple way to implement this simply adds new configuration from<br>
new files, if a file gets changed or deleted, then the dhcp-hosts that<br>
were created by its old contents are not deleted, and SIGUSR1 is still<br>
needed to re-read the config from scratch and garbage collect old<br>
entries. More complex implementation would keep track which dhcp-hosts<br>
are associated with which files, and delete old versions when a file<br>
changes. I'd rather not have to do the more complex version, is it can<br>
be avoided.<br>
<br>
Comments?<br><br></div></blockquote></div><div class="gmail_extra"><br></div>Thanks Simon! I will currently use some workaround and wait for the super inotify solution. <br clear="all"><div><br></div>-- <br><div>Yongkang You</div>
</div></div>