s3: Fix a long-standing problem with recycled PIDs
[sfrench/samba-autobuild/.git] / source3 / nmbd / nmbd.c
index 22f5b9711650bb3478438f559b1d6cd360b0c5e7..4443dfae9f87f54df5b39eb4a0526c7600749ea9 100644 (file)
@@ -83,6 +83,7 @@ static void terminate(void)
        kill_async_dns_child();
 
        gencache_stabilize();
+       serverid_deregister_self();
 
        pidfile_unlink();
 
@@ -930,7 +931,11 @@ static bool open_sockets(bool isdaemon, int port)
                exit(1);
 
        /* get broadcast messages */
-       claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
+
+       if (!serverid_register_self(FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
+               DEBUG(1, ("Could not register myself in serverid.tdb\n"));
+               exit(1);
+       }
 
        messaging_register(nmbd_messaging_context(), NULL,
                           MSG_FORCE_ELECTION, nmbd_message_election);