From 96629d7d8ed0ca62c1c4fc660c9e732f2005999f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 Jun 2012 12:02:04 -0700 Subject: [PATCH 1/2] Stop spamming the logs with "Could not remove pid XX from serverid.tdb" messages and initiating the cleanup function on every process deat We now have many sub-processes from smbd that don't serve SMB1/SMB2 requests and don't register themselves in the serverid.tdb. Only initiate the cleanup from processes that were explicitly in the child list. --- source3/smbd/server.c | 35 +++++++++++++++++++---------------- 1 files changed, 19 insertions(+), 16 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 8cda180..9a8cdc0 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -283,6 +283,25 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown) static struct timed_event *cleanup_te; struct server_id child_id; + child_id = procid_self(); /* Just initialize pid and potentially vnn */ + child_id.pid = pid; + + for (child = children; child != NULL; child = child->next) { + if (child->pid == pid) { + struct child_pid *tmp = child; + DLIST_REMOVE(children, child); + SAFE_FREE(tmp); + num_children -= 1; + break; + } + } + + if (child == NULL) { + /* not all forked child processes are added to the children list */ + DEBUG(2, ("Could not find child %d -- ignoring\n", (int)pid)); + return; + } + if (unclean_shutdown) { /* a child terminated uncleanly so tickle all processes to see if they can grab any of the @@ -301,26 +320,10 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown) } } - child_id = procid_self(); /* Just initialize pid and potentially vnn */ - child_id.pid = pid; - if (!serverid_deregister(child_id)) { DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", (int)pid)); } - - for (child = children; child != NULL; child = child->next) { - if (child->pid == pid) { - struct child_pid *tmp = child; - DLIST_REMOVE(children, child); - SAFE_FREE(tmp); - num_children -= 1; - return; - } - } - - /* not all forked child processes are added to the children list */ - DEBUG(1, ("Could not find child %d -- ignoring\n", (int)pid)); } /**************************************************************************** -- 1.7.7.3 From efa813fea49c9275842b3931054dafa26fc47a7a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 Jun 2012 12:28:33 -0700 Subject: [PATCH 2/2] We are triggering the cleanup_timeout_fn() too often, on exiting when an smbd is idle. Calls to exit_server_cleanly() should be treated as a "clean" shutdown, and not trigger the master smbd to call cleanup_timeout_fn. --- source3/smbd/server_exit.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-) diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c index 4c71d8f..fc77dee 100644 --- a/source3/smbd/server_exit.c +++ b/source3/smbd/server_exit.c @@ -83,7 +83,6 @@ static void exit_server_common(enum server_exit_reason how, static void exit_server_common(enum server_exit_reason how, const char *const reason) { - bool had_open_conn = false; struct smbd_server_connection *sconn = smbd_server_conn; if (!exit_firsttime) @@ -101,7 +100,7 @@ static void exit_server_common(enum server_exit_reason how, bool found = false; files_forall(sconn, log_writeable_file_fn, &found); } - had_open_conn = conn_close_all(sconn); + (void)conn_close_all(sconn); invalidate_all_vuids(sconn); } @@ -175,6 +174,8 @@ static void exit_server_common(enum server_exit_reason how, dump_core(); + /* Notreached. */ + exit(1); } else { DEBUG(3,("Server exit (%s)\n", (reason ? reason : "normal exit"))); @@ -184,15 +185,7 @@ static void exit_server_common(enum server_exit_reason how, gencache_stabilize(); } - /* if we had any open SMB connections when we exited then we - need to tell the parent smbd so that it can trigger a retry - of any locks we may have been holding or open files we were - blocking */ - if (had_open_conn) { - exit(1); - } else { - exit(0); - } + exit(0); } void exit_server(const char *const explanation) -- 1.7.7.3