summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-08-07 17:19:39 +1000
committerAndrew Tridgell <tridge@samba.org>2009-08-07 17:24:48 +1000
commitcfc0cabb27c7323930b96dd93befa955bacd6cde (patch)
tree6888fc1fe19864d47f4b66d235ec116f9063948f /source4
parent2c12c985e7f2debb25452e484925b7fdf987c659 (diff)
downloadsamba-cfc0cabb27c7323930b96dd93befa955bacd6cde.tar.gz
samba-cfc0cabb27c7323930b96dd93befa955bacd6cde.tar.bz2
samba-cfc0cabb27c7323930b96dd93befa955bacd6cde.zip
prime the sam ldb schema in the parent samba process
While testing the use of the standard process model with 'make test' I found that testing was much slower (by several times) with the standard model than with the single model. The primary problem was that each SMB connection would open a new sam ldb context, and all of those would reload the full AD schema. The fix is to pre-open the SAM during server startup, before any child processes are forked. This sets up the global schema context which is inherited by all connections. The standard model is still slower at make test than the single model, but not by nearly as much. I am working on further reducing the gap.
Diffstat (limited to 'source4')
-rw-r--r--source4/smbd/server.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 635e84fafe..bb2571e819 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -38,6 +38,8 @@
#include "param/secrets.h"
#include "smbd/pidfile.h"
#include "param/param.h"
+#include "dsdb/samdb/samdb.h"
+#include "auth/session.h"
/*
recursively delete a directory tree
@@ -112,6 +114,7 @@ static void sig_term(int sig)
kill(-getpgrp(), SIGTERM);
}
#endif
+ DEBUG(0,("Exiting pid %d on SIGTERM\n", (int)getpid()));
exit(0);
}
@@ -157,6 +160,7 @@ static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent
DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name));
#if HAVE_GETPGRP
if (getpgrp() == getpid()) {
+ DEBUG(0,("Sending SIGTERM from pid %d\n", (int)getpid()));
kill(-getpgrp(), SIGTERM);
}
#endif
@@ -177,6 +181,18 @@ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev,
}
/*
+ pre-open the sam ldb to ensure the schema has been loaded. This
+ saves a lot of time in child processes
+ */
+static void prime_samdb_schema(struct tevent_context *event_ctx)
+{
+ TALLOC_CTX *samdb_context;
+ samdb_context = talloc_new(event_ctx);
+ samdb_connect(samdb_context, event_ctx, cmdline_lp_ctx, system_session(samdb_context, cmdline_lp_ctx));
+ talloc_free(samdb_context);
+}
+
+/*
main server.
*/
static int binary_smbd_main(const char *binary_name, int argc, const char *argv[])
@@ -344,6 +360,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
discard_const(binary_name));
}
+ prime_samdb_schema(event_ctx);
+
DEBUG(0,("%s: using '%s' process model\n", binary_name, model));
status = server_service_startup(event_ctx, cmdline_lp_ctx, model,
lp_server_services(cmdline_lp_ctx));