if you enter "/etc/init.d/dnsmasq restart" and "killall -HUP dnsmasq" (as in the dhcp scripts) at the same time its racy. killall will also send a HUP signal to the init script, which is killed then.

I found this while investigating a non running dnsmasq after system start.
Thought this was the issue, however I still have a non running dnsmas from time to time.
Still investigating further how this can happen...

Anyway, its better to explicitly send the HUP signal to the process in the pid file
instead of all dnsmasq processes (like the init script too).

On 01/15/2014 03:06 PM, John Crispin wrote:
Hi,

On 15/01/2014 11:43, Ulrich Weber wrote:
avoids nasty race condition between manual "dnsmasq restart" and
"killall -HUP dnsmasq" by dhcp client, killing the init script accidentially
please make a more elaborate description of what race you mean

     John





Signed-off-by: Ulrich Weber <u...@xyne.com>
---
  package/network/ipv6/6relayd/files/6relayd-update   | 2 +-
  package/network/services/dnsmasq/files/dnsmasq.init | 9 +++++++++
  package/network/services/odhcpd/files/odhcpd-update | 2 +-
  3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/package/network/ipv6/6relayd/files/6relayd-update 
b/package/network/ipv6/6relayd/files/6relayd-update
index 20980f2..c72c88a 100755
--- a/package/network/ipv6/6relayd/files/6relayd-update
+++ b/package/network/ipv6/6relayd/files/6relayd-update
@@ -1,3 +1,3 @@
  #!/bin/sh
  # Make dnsmasq reread hostfile
-killall -SIGHUP dnsmasq
+/etc/init.d/dnsmasq reload
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init 
b/package/network/services/dnsmasq/files/dnsmasq.init
index 0ff987f..5d33557 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -579,6 +579,15 @@ reload_service() {
        return 0
  }
+reload_service() {
+       DNSMASQ_PID=$(cat /var/run/dnsmasq.pid)
+
+       if [ "$DNSMASQ_PID" != "" ]
+       then
+               kill -s HUP $DNSMASQ_PID
+       fi
+}
+
  stop_service() {
        [ -f /tmp/resolv.conf ] && {
                rm -f /tmp/resolv.conf
diff --git a/package/network/services/odhcpd/files/odhcpd-update 
b/package/network/services/odhcpd/files/odhcpd-update
index 20980f2..c72c88a 100755
--- a/package/network/services/odhcpd/files/odhcpd-update
+++ b/package/network/services/odhcpd/files/odhcpd-update
@@ -1,3 +1,3 @@
  #!/bin/sh
  # Make dnsmasq reread hostfile
-killall -SIGHUP dnsmasq
+/etc/init.d/dnsmasq reload
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to