Fix CLEAR_IF_FIRST handling of messages.tdb
authorVolker Lendecke <vl@samba.org>
Wed, 23 Apr 2008 15:13:50 +0000 (17:13 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 23 Apr 2008 20:18:26 +0000 (22:18 +0200)
We now open messages.tdb even before we do the become_daemon. become_daemon()
involves a fork and an immediate exit of the parent, thus the
parent_is_longlived argument must be set to false in this case. The parent is
not really long lived :-)
(This used to be commit 4f4781c6d17fe2db34dd5945fec52a7685448aec)

source3/lib/util.c
source3/nmbd/asyncdns.c
source3/nmbd/nmbd.c
source3/printing/printing.c
source3/smbd/server.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c

index db0da541f9afcd314953a1e94c8904f698f630ec..953981e82ade57c85b2b0817a160603f035db373 100644 (file)
@@ -990,7 +990,8 @@ void become_daemon(bool Fork, bool no_process_group)
                                  attach it to the logfile */
 }
 
-bool reinit_after_fork(struct messaging_context *msg_ctx)
+bool reinit_after_fork(struct messaging_context *msg_ctx,
+                      bool parent_longlived)
 {
        NTSTATUS status;
 
@@ -1001,7 +1002,7 @@ bool reinit_after_fork(struct messaging_context *msg_ctx)
        set_need_random_reseed();
 
        /* tdb needs special fork handling */
-       if (tdb_reopen_all(1) == -1) {
+       if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
                DEBUG(0,("tdb_reopen_all failed.\n"));
                return false;
        }
index 0329491c4a6b6529df24b00c9549b9229a9f12cb..ab9b1ed740eeb1b324e4e506ecf8037a5fd60b74 100644 (file)
@@ -164,7 +164,7 @@ void start_async_dns(void)
        CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, SIGNAL_CAST sig_term );
 
-       if (!reinit_after_fork(nmbd_messaging_context())) {
+       if (!reinit_after_fork(nmbd_messaging_context(), true)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
index 9396219ea7282553c3376ee6ea181c57232f24b1..af4acc84d07a217fa5e9f43bfabe97702aa603d9 100644 (file)
@@ -912,7 +912,7 @@ static bool open_sockets(bool isdaemon, int port)
 
        pidfile_create("nmbd");
 
-       if (!reinit_after_fork(nmbd_messaging_context())) {
+       if (!reinit_after_fork(nmbd_messaging_context(), false)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
index fdf5e6cc224da9a5c9987c0981fd4c9b07fb41f5..c5fe53f04267690fb0447c9efb69f998ae9b6e5f 100644 (file)
@@ -1406,7 +1406,7 @@ void start_background_queue(void)
                /* Child. */
                DEBUG(5,("start_background_queue: background LPQ thread started\n"));
 
-               if (!reinit_after_fork(smbd_messaging_context())) {
+               if (!reinit_after_fork(smbd_messaging_context(), true)) {
                        DEBUG(0,("reinit_after_fork() failed\n"));
                        smb_panic("reinit_after_fork() failed");
                }
index 59bbfdbc17678109addb7dcbdeda07ebdf655a61..cf02589864c66b4baf8f46cd6f8c2c9ebaac9c40 100644 (file)
@@ -739,7 +739,8 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
                                                                sizeof(remaddr)),
                                                                false);
 
-                               if (!reinit_after_fork(smbd_messaging_context())) {
+                               if (!reinit_after_fork(
+                                           smbd_messaging_context(), true)) {
                                        DEBUG(0,("reinit_after_fork() failed\n"));
                                        smb_panic("reinit_after_fork() failed");
                                }
@@ -1285,7 +1286,7 @@ extern void build_options(bool screen);
        if (is_daemon)
                pidfile_create("smbd");
 
-       if (!reinit_after_fork(smbd_messaging_context())) {
+       if (!reinit_after_fork(smbd_messaging_context(), false)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
index 64674b8ace0235ef901af88dcf9f9384347c8f78..1072f8e762b39de0802607d9cdd2054c880d9663 100644 (file)
@@ -1189,7 +1189,7 @@ int main(int argc, char **argv, char **envp)
 
        TimeInit();
 
-       if (!reinit_after_fork(winbind_messaging_context())) {
+       if (!reinit_after_fork(winbind_messaging_context(), false)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
index c62476e5ebe42b7691f63efa2a8d6b59a20363e0..822f946e1a25a78e4e439a5d26158e7b89a1a626 100644 (file)
@@ -199,7 +199,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
 
        /* Leave messages blocked - we will never process one. */
 
-       if (!reinit_after_fork(winbind_messaging_context())) {
+       if (!reinit_after_fork(winbind_messaging_context(), true)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                _exit(0);
        }
index 77fbe3c0ed401b4dbcc6e830a65fd155d53bbf74..14ba38cef32c1261a0592960ff1346083372a1bc 100644 (file)
@@ -1005,7 +1005,7 @@ static bool fork_domain_child(struct winbindd_child *child)
        state.sock = fdpair[0];
        close(fdpair[1]);
 
-       if (!reinit_after_fork(winbind_messaging_context())) {
+       if (!reinit_after_fork(winbind_messaging_context(), true)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                _exit(0);
        }