[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-872-g7c20256

Andrew Tridgell tridge at samba.org
Fri Aug 7 01:25:10 MDT 2009


The branch, master has been updated
       via  7c2025610c7dfce228f682f2f204972b0264cf72 (commit)
       via  c271dc998ba25101a46e7d4b2187567a07588ca2 (commit)
       via  cfc0cabb27c7323930b96dd93befa955bacd6cde (commit)
       via  2c12c985e7f2debb25452e484925b7fdf987c659 (commit)
       via  e2d4ae15107c8613707adc68ffc68c6ced04e9be (commit)
      from  238bf25af44ecc51bef59f1d0b9303da9904432e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7c2025610c7dfce228f682f2f204972b0264cf72
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 7 17:23:52 2009 +1000

    fixed another ambiguous talloc call
    
    During the creation of the 3 RPC pipes in winbind we try to steal the
    RPC binding structure to be a child of the pipe once the pipe is
    established. This fails with a talloc warning as the rpc connection
    code already holds a reference to the binding.
    
    The fix is to use talloc_reparent() instead.

commit c271dc998ba25101a46e7d4b2187567a07588ca2
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 7 17:21:54 2009 +1000

    ensure that child tasks die when the parent dies
    
    Previously we relied on process groups and SIGTERM to ensure that
    child tasks died in the standard process model when the parent task
    died. This doesn't work when the server is run in interactive mode, as
    in that case we don't call become_daemon() and don't get a separate
    process group.
    
    The fix is to have a pipe held open by the parent server process, and
    inherited by child tasks. If the parent exits then the write side of
    the pipe is implicitly closed, which causes an event in the child
    tasks that causes them to exit

commit cfc0cabb27c7323930b96dd93befa955bacd6cde
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 7 17:19:39 2009 +1000

    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.

commit 2c12c985e7f2debb25452e484925b7fdf987c659
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 7 17:16:26 2009 +1000

    use talloc with the global schema consistently
    
    Before this change, the first opener of the sam ldb context would
    become the owner of the global schema, then the autofree context got a
    reference to the schema. Any subsequent opens of the sam ldb also got
    a reference. This meant that the talloc hierarchy was inconsistent
    between the first sam ldb open and subsequent opens. With this change
    the autofree context becomes the owner of the global schema, and all
    ldb contexts get a reference.

commit e2d4ae15107c8613707adc68ffc68c6ced04e9be
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 7 17:14:13 2009 +1000

    fixed several places that unnecessarily take a reference to the event context
    
    These references were triggering the ambiguous talloc_free errors from
    the recent talloc changes when the server is run using the 'standard'
    process model instead of the 'single' process model. I am aiming to
    move the build farm to use the 'standard' process model soon, as part
    of an effort to make our test environment better match the real
    deployment of Samba4.
    
    The references are not needed as the way that the event context is
    used is as the 'top parent', so when the event context is freed then
    all of the structures that were taking a reference to the event
    context were actually freed as well, thus making the references
    redundent.

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/samdb/ldb_modules/samldb.c |    4 ----
 source4/dsdb/schema/schema_set.c        |    3 ++-
 source4/lib/messaging/messaging.c       |    2 +-
 source4/libcli/composite/composite.c    |    6 +-----
 source4/libcli/dgram/dgramsocket.c      |    2 +-
 source4/libcli/raw/clisocket.c          |    5 ++---
 source4/libcli/smb_composite/connect.c  |    2 +-
 source4/libcli/wrepl/winsrepl.c         |    4 ++--
 source4/librpc/rpc/dcerpc.c             |    2 +-
 source4/nbt_server/wins/winswack.c      |    4 ++--
 source4/smbd/process_standard.c         |   24 ++++++++++++++++++++++++
 source4/smbd/server.c                   |   18 ++++++++++++++++++
 source4/winbind/wb_init_domain.c        |    6 +++---
 13 files changed, 58 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 544249c..037d5c9 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -244,10 +244,6 @@ static int samldb_search_template(struct samldb_ctx *ac)
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 
-		if (!talloc_reference(templates_ldb, ev)) {
-			return LDB_ERR_OPERATIONS_ERROR;
-		}
-
 		ret = ldb_set_opaque(ldb,
 					"templates_ldb", templates_ldb);
 		if (ret != LDB_SUCCESS) {
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 5ded04e..5d78d0a 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -437,7 +437,8 @@ void dsdb_make_schema_global(struct ldb_context *ldb)
 	}
 
 	/* we want the schema to be around permanently */
-	talloc_reference(talloc_autofree_context(), schema);
+	talloc_reparent(talloc_parent(schema), talloc_autofree_context(), schema);
+
 	global_schema = schema;
 
 	dsdb_set_global_schema(ldb);
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index cfceeff..277688e 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -596,7 +596,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 	/* it needs to be non blocking for sends */
 	set_blocking(socket_get_fd(msg->sock), false);
 
-	msg->event.ev   = talloc_reference(msg, ev);
+	msg->event.ev   = ev;
 	msg->event.fde	= event_add_fd(ev, msg, socket_get_fd(msg->sock), 
 				       EVENT_FD_READ, messaging_handler, msg);
 
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index ab32175..7262ebc 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -42,11 +42,7 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
 	c = talloc_zero(mem_ctx, struct composite_context);
 	if (!c) return NULL;
 	c->state = COMPOSITE_STATE_IN_PROGRESS;
-	c->event_ctx = talloc_reference(c, ev);
-	if (!c->event_ctx) {
-		talloc_free(c);
-		return NULL;
-	}
+	c->event_ctx = ev;
 
 	return c;
 }
diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c
index 751706d..365960e 100644
--- a/source4/libcli/dgram/dgramsocket.c
+++ b/source4/libcli/dgram/dgramsocket.c
@@ -166,7 +166,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
 	dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
 	if (dgmsock == NULL) goto failed;
 
-	dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
+	dgmsock->event_ctx = event_ctx;
 	if (dgmsock->event_ctx == NULL) goto failed;
 
 	status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index b9e8321..02da491 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -61,7 +61,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
 	if (result == NULL) goto failed;
 	result->state = COMPOSITE_STATE_IN_PROGRESS;
 
-	result->event_ctx = talloc_reference(result, event_ctx);
+	result->event_ctx = event_ctx;
 	if (result->event_ctx == NULL) goto failed;
 
 	state = talloc(result, struct sock_connect_state);
@@ -118,8 +118,7 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
 	state->result->port = port;
 	state->result->hostname = talloc_steal(sock, state->host_name);
 
-	state->result->event.ctx =
-		talloc_reference(state->result, state->ctx->event_ctx);
+	state->result->event.ctx = state->ctx->event_ctx;
 	if (composite_nomem(state->result->event.ctx, state->ctx)) return;
 
 	composite_done(state->ctx);
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index a5d05b7..9a19771 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -466,7 +466,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
 	c = talloc_zero(mem_ctx, struct composite_context);
 	if (c == NULL) goto failed;
 
-	c->event_ctx = talloc_reference(c, event_ctx);
+	c->event_ctx = event_ctx;
 	if (c->event_ctx == NULL) goto failed;
 
 	state = talloc_zero(c, struct connect_state);
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 48a6abb..849511b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -171,7 +171,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
 	wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
 	if (!wrepl_socket) return NULL;
 
-	wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
+	wrepl_socket->event.ctx = event_ctx;
 	if (!wrepl_socket->event.ctx) goto failed;
 
 	wrepl_socket->iconv_convenience = iconv_convenience;
@@ -205,7 +205,7 @@ struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx,
 	wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
 	if (wrepl_socket == NULL) goto failed;
 
-	wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
+	wrepl_socket->event.ctx = event_ctx;
 	if (wrepl_socket->event.ctx == NULL) goto failed;
 
 	wrepl_socket->sock = sock;
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 0ae56a4..cc13319 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -67,7 +67,7 @@ static struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
 
 	c->iconv_convenience = talloc_reference(c, ic);
 
-	c->event_ctx = talloc_reference(c, ev);
+	c->event_ctx = ev;
 
 	if (c->event_ctx == NULL) {
 		talloc_free(c);
diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c
index c53fa1d..a583628 100644
--- a/source4/nbt_server/wins/winswack.c
+++ b/source4/nbt_server/wins/winswack.c
@@ -94,7 +94,7 @@ struct composite_context *wins_challenge_send(TALLOC_CTX *mem_ctx, struct wins_c
 	result = talloc_zero(mem_ctx, struct composite_context);
 	if (result == NULL) return NULL;
 	result->state = COMPOSITE_STATE_IN_PROGRESS;
-	result->event_ctx = talloc_reference(result, io->in.event_ctx);
+	result->event_ctx = io->in.event_ctx;
 
 	state = talloc_zero(result, struct wins_challenge_state);
 	if (state == NULL) goto failed;
@@ -204,7 +204,7 @@ static struct composite_context *wins_release_demand_send(TALLOC_CTX *mem_ctx, s
 	result = talloc_zero(mem_ctx, struct composite_context);
 	if (result == NULL) return NULL;
 	result->state = COMPOSITE_STATE_IN_PROGRESS;
-	result->event_ctx = talloc_reference(result, io->in.event_ctx);
+	result->event_ctx = io->in.event_ctx;
 
 	state = talloc_zero(result, struct wins_release_demand_state);
 	if (state == NULL) goto failed;
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 137e0a7..730e185 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -44,15 +44,31 @@ static int none_setproctitle(const char *fmt, ...)
 }
 #endif
 
+/* we hold a pipe open in the parent, and the any child
+   processes wait for EOF on that pipe. This ensures that
+   children die when the parent dies */
+static int child_pipe[2];
+
 /*
   called when the process model is selected
 */
 static void standard_model_init(struct tevent_context *ev)
 {
+	pipe(child_pipe);
 	signal(SIGCHLD, SIG_IGN);
 }
 
 /*
+  handle EOF on the child pipe
+*/
+static void standard_pipe_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, 
+				  uint16_t flags, void *private_data)
+{
+	DEBUG(10,("Child %d exiting\n", (int)getpid()));
+	exit(0);
+}
+
+/*
   called when a listening socket becomes readable. 
 */
 static void standard_accept_connection(struct tevent_context *ev, 
@@ -114,6 +130,10 @@ static void standard_accept_connection(struct tevent_context *ev,
 		DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
 	}
 
+	tevent_add_fd(ev2, ev2, child_pipe[0], TEVENT_FD_READ,
+		      standard_pipe_handler, NULL);
+	close(child_pipe[1]);
+
 	/* Ensure that the forked children do not expose identical random streams */
 	set_need_random_reseed();
 
@@ -177,6 +197,10 @@ static void standard_new_task(struct tevent_context *ev,
 		DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
 	}
 
+	tevent_add_fd(ev2, ev2, child_pipe[0], TEVENT_FD_READ,
+		      standard_pipe_handler, NULL);
+	close(child_pipe[1]);
+
 	/* Ensure that the forked children do not expose identical random streams */
 	set_need_random_reseed();
 
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 635e84f..bb2571e 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));
diff --git a/source4/winbind/wb_init_domain.c b/source4/winbind/wb_init_domain.c
index 6767466..1f560c1 100644
--- a/source4/winbind/wb_init_domain.c
+++ b/source4/winbind/wb_init_domain.c
@@ -211,7 +211,7 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
 	if (!composite_is_ok(state->ctx)) {
 		return;
 	}
-	talloc_steal(state->domain->netlogon_pipe, state->domain->netlogon_binding);
+	talloc_reparent(state, state->domain->netlogon_pipe, state->domain->netlogon_binding);
 
 	state->domain->lsa_binding = init_domain_binding(state, &ndr_table_lsarpc);
 
@@ -286,7 +286,7 @@ static void init_domain_recv_lsa_pipe(struct composite_context *ctx)
 	if (!composite_is_ok(state->ctx)) return;
 
 	talloc_steal(state->domain->libnet_ctx, state->domain->libnet_ctx->lsa.pipe);
-	talloc_steal(state->domain->libnet_ctx->lsa.pipe, state->domain->lsa_binding);
+	talloc_reparent(state, state->domain->libnet_ctx->lsa.pipe, state->domain->lsa_binding);
 	state->domain->libnet_ctx->lsa.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
 	state->domain->libnet_ctx->lsa.name = state->domain->info->name;
 
@@ -399,7 +399,7 @@ static void init_domain_recv_samr(struct composite_context *ctx)
 		&state->domain->libnet_ctx->samr.handle);
 	if (!composite_is_ok(state->ctx)) return;
 
-	talloc_steal(state->domain->libnet_ctx->samr.pipe, state->domain->samr_binding);
+	talloc_reparent(state, state->domain->libnet_ctx->samr.pipe, state->domain->samr_binding);
 	state->domain->libnet_ctx->samr.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
 	state->domain->libnet_ctx->samr.name = state->domain->info->name;
 	state->domain->libnet_ctx->samr.sid = dom_sid_dup(


-- 
Samba Shared Repository


More information about the samba-cvs mailing list