An old NSD daemon, stuck with old data?

Miek Gieben miekg at atoom.net
Thu Nov 24 10:27:21 UTC 2005


[On 22 Nov, @11:14, Stephane Bortzmeyer wrote in "An old NSD daemon, stuck with  ..."]
> problem. Is it possible that the "old" daemons were still receiving
> some of the UDP requests (I did not test with TCP, unfortunately) and

You are hit by a tricky race condition in the NSD code. The following
patch minimizes the race window. This patch will be in nsd 2.3.2.

For nsd 2.3.3 I will refactor the sig_handler.



Index: nsd.c
===================================================================
--- nsd.c       (revision 1724)
+++ nsd.c       (working copy)
@@ -167,6 +167,7 @@
 sig_handler (int sig)
 {
        size_t i;
+       /* To avoid race cond. We really don't want to use log_msg() in this handler */

        /* Are we a child server? */
        if (nsd.server_kind != NSD_SERVER_MAIN) {
@@ -197,7 +198,7 @@
        case SIGCHLD:
                return;
        case SIGHUP:
-               log_msg(LOG_WARNING, "signal %d received, reloading...", sig);
+               /* log_msg(LOG_WARNING, "signal %d received, reloading...", sig); */
                nsd.mode = NSD_RELOAD;
                return;
        case SIGALRM:
@@ -223,7 +224,7 @@
        case SIGTERM:
        default:
                nsd.mode = NSD_SHUTDOWN;
-               log_msg(LOG_WARNING, "signal %d received, shutting down...", sig);
+               /* log_msg(LOG_WARNING, "signal %d received, shutting down...", sig); */
                sig = SIGTERM;
                break;
        }
Index: server.c
===================================================================
--- server.c    (revision 1724)
+++ server.c    (working copy)
@@ -460,6 +460,8 @@
                                break;
                        }

+                       log_msg(LOG_WARNING, "signal received, reloading...");
+
                        reload_pid = fork();
                        switch (reload_pid) {
                        case -1:
@@ -520,6 +522,7 @@
                        server_shutdown(nsd);
                        break;
                case NSD_SHUTDOWN:
+                       log_msg(LOG_WARNING, "signal received, shutting down...");
                        break;
                default:
                        log_msg(LOG_WARNING, "NSD main server mode invalid: %d", nsd->mode);

--
grtz,
  - Miek

 http://www.miek.nl                      http://www.nlnetlabs.nl
  PGP Key ID: 3880 D0F6
 fingerprint: 6A3C F450 6D4E 7C6B C23C  F982 258B 85CF 3880 D0F6
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.nlnetlabs.nl/pipermail/nsd-users/attachments/20051124/541e91b6/attachment.bin>


More information about the nsd-users mailing list