Allow reinit_after_fork to be called safely from within swat and other binaries that...
authorJeremy Allison <jra@samba.org>
Thu, 15 Jan 2009 23:52:41 +0000 (15:52 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 15 Jan 2009 23:52:41 +0000 (15:52 -0800)
an event context or a msg context. Fixes crash bug in swat.
Jeremy.

source3/lib/util.c

index 1e6ee562302219176fdfbec2dcd5298506897729..70eabbfa99e9fb80a1751c49b7524e9477dc6008 100644 (file)
@@ -966,18 +966,22 @@ bool reinit_after_fork(struct messaging_context *msg_ctx,
                return false;
        }
 
-       /*
-        * For clustering, we need to re-init our ctdbd connection after the
-        * fork
-        */
-       status = messaging_reinit(msg_ctx);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0,("messaging_reinit() failed: %s\n",
-                        nt_errstr(status)));
-               return false;
+       if (msg_ctx) {
+               /*
+                * For clustering, we need to re-init our ctdbd connection after the
+                * fork
+                */
+               status = messaging_reinit(msg_ctx);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0,("messaging_reinit() failed: %s\n",
+                                nt_errstr(status)));
+                       return false;
+               }
        }
 
-       event_context_reinit(ev_ctx);
+       if (ev_ctx) {
+               event_context_reinit(ev_ctx);
+       }
 
        return true;
 }