From 14fc9018aa8abfd3255f0f3a1b2b5541e8a9dc61 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 6 Nov 2015 17:01:02 +0100 Subject: [PATCH] smbd: Move serverid_deregister() to the cleanupd Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/server.c | 8 -------- source3/smbd/smbd_cleanupd.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index ff259dd2d6e..b83cfdd33f6 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -555,12 +555,9 @@ static void remove_child_pid(struct smbd_parent_context *parent, bool unclean_shutdown) { struct smbd_child_pid *child; - struct server_id child_id; struct iovec iov[2]; NTSTATUS status; - child_id = pid_to_procid(pid); - iov[0] = (struct iovec) { .iov_base = (uint8_t *)&pid, .iov_len = sizeof(pid) }; iov[1] = (struct iovec) { .iov_base = (uint8_t *)&unclean_shutdown, @@ -605,11 +602,6 @@ static void remove_child_pid(struct smbd_parent_context *parent, DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n")); } } - - if (!serverid_deregister(child_id)) { - DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", - (int)pid)); - } } /**************************************************************************** diff --git a/source3/smbd/smbd_cleanupd.c b/source3/smbd/smbd_cleanupd.c index 90a054f1086..e931a28e8a9 100644 --- a/source3/smbd/smbd_cleanupd.c +++ b/source3/smbd/smbd_cleanupd.c @@ -19,9 +19,11 @@ #include "replace.h" #include "smbd_cleanupd.h" +#include "lib/util_procid.h" #include "lib/util/tevent_ntstatus.h" #include "lib/util/debug.h" #include "smbprofile.h" +#include "serverid.h" struct smbd_cleanupd_state { pid_t parent_pid; @@ -86,6 +88,7 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg, struct smbd_cleanupd_state *state = tevent_req_data( req, struct smbd_cleanupd_state); pid_t pid; + struct server_id child_id; bool unclean_shutdown; int ret; @@ -101,6 +104,14 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg, DBG_DEBUG("%d exited %sclean\n", (int)pid, unclean_shutdown ? "un" : ""); + /* + * Get child_id before messaging_cleanup which wipes the + * unique_id. Not that it really matters here for functionality (the + * child should have properly cleaned up :-)) though, but it looks + * nicer. + */ + child_id = pid_to_procid(pid); + smbprofile_cleanup(pid, state->parent_pid); ret = messaging_cleanup(msg, pid); @@ -108,6 +119,11 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg, if ((ret != 0) && (ret != ENOENT)) { DBG_DEBUG("messaging_cleanup returned %s\n", strerror(ret)); } + + if (!serverid_deregister(child_id)) { + DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", + (int)pid)); + } } NTSTATUS smbd_cleanupd_recv(struct tevent_req *req) -- 2.34.1