smbd: Always clean up the child's msg_ctx
authorVolker Lendecke <vl@samba.org>
Fri, 11 Apr 2014 07:13:10 +0000 (09:13 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 23 Apr 2014 20:33:08 +0000 (22:33 +0200)
This is a bit lazy programming, we could and possibly should do this in
exit_server() in the child. But this way we make sure the cleanup works. If it
only was executed for unclean exits, we might not detect failure of this code
in the parent.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/server.c

index df565cf0aea7bfdc541ab12ed52acc3e4fdf73b0..5c764be92352ba0d654132b7190ac88722b63233 100644 (file)
@@ -445,9 +445,14 @@ static void remove_child_pid(struct smbd_parent_context *parent,
 {
        struct smbd_child_pid *child;
        struct server_id child_id;
+       NTSTATUS status;
 
        child_id = pid_to_procid(pid);
 
+       status = messaging_dgm_cleanup(parent->msg_ctx, pid);
+       DEBUG(10, ("%s: messaging_dgm_cleanup returned %s\n",
+                  __func__, nt_errstr(status)));
+
        for (child = parent->children; child != NULL; child = child->next) {
                if (child->pid == pid) {
                        struct smbd_child_pid *tmp = child;
@@ -465,8 +470,6 @@ static void remove_child_pid(struct smbd_parent_context *parent,
        }
 
        if (unclean_shutdown) {
-               NTSTATUS status;
-
                /* a child terminated uncleanly so tickle all
                   processes to see if they can grab any of the
                   pending locks
@@ -483,10 +486,6 @@ static void remove_child_pid(struct smbd_parent_context *parent,
                                                parent);
                        DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n"));
                }
-
-               status = messaging_dgm_cleanup(parent->msg_ctx, pid);
-               DEBUG(10, ("%s: messaging_dgm_cleanup returned %s\n",
-                          __func__, nt_errstr(status)));
        }
 
        if (!serverid_deregister(child_id)) {