[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha2-619-g35313c0

Andrew Bartlett abartlet at samba.org
Mon Feb 4 07:04:04 GMT 2008


The branch, v4-0-test has been updated
       via  35313c0aa3fbfdd943edfb7bafd7645b1a0c54e9 (commit)
       via  c961e7d74e33a0dd61b1053620fb41521322e20d (commit)
       via  931994a7f185bbc98924823e9e8cef1011dd0957 (commit)
       via  0d830580e3539c96da3aa6c72fafe6eacd7a74a0 (commit)
       via  377a7c633d4813c134b91739c507dcefb55c9691 (commit)
       via  8011716734cb8e3c34f85d9d68201f13cb5b8e0a (commit)
       via  81a0a7967b8f659f1f35a7a25de469725417ab43 (commit)
       via  f0a4db22e58d393be5b28f767ee6d0abfc8f11dc (commit)
       via  74220ca244865f97825cabdbc8aa899e71c25c7d (commit)
       via  8831a5c7935f7e2181252b7b6561541b8c8db679 (commit)
      from  ec0ee2aa5f4bef32f09a426d91c28c985f843038 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 35313c0aa3fbfdd943edfb7bafd7645b1a0c54e9
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 4 17:59:16 2008 +1100

    Remaining changes to implement the prefork process model
    
    To use, run 'smbd -M prefork'
    
    By default, only the smb service is preforked.  4 children are
    created, and all listen for new connections.  The Linux Kernel 'wake
    one' behaviour should ensure that only one is given the oportunity to
    accept.  We need to look into the ideal number of worker children, as
    well as load balancing behaviours.
    
    To change, set:
    
    prefork children : smb = 6
    
    valid service names (smb in this example) match those in 'server services'.
    
    Andrew Bartlett and David Disseldorp

commit c961e7d74e33a0dd61b1053620fb41521322e20d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 4 17:53:01 2008 +1100

    Rework process_single.c to take advantage of cluster_id() now taking an additional argument.
    
    Andrew Bartlett and David Disseldorp

commit 931994a7f185bbc98924823e9e8cef1011dd0957
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 4 17:51:38 2008 +1100

    Rework cluster_id() to take an additional argument, as we need
    <node>.<pid>.<fd> to be unique in a prefork process environment.
    
    Andrew Bartlett and David Disseldorp

commit 0d830580e3539c96da3aa6c72fafe6eacd7a74a0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 4 17:48:51 2008 +1100

    Rework service init functions to pass down service name.  This is
    needed to change prefork behaviour based on what service is being
    started.
    
    Andrew Bartlett and David Disseldorp

commit 377a7c633d4813c134b91739c507dcefb55c9691
Merge: 8011716734cb8e3c34f85d9d68201f13cb5b8e0a ec0ee2aa5f4bef32f09a426d91c28c985f843038
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 4 09:56:24 2008 +1100

    Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-abartlet

commit 8011716734cb8e3c34f85d9d68201f13cb5b8e0a
Merge: 81a0a7967b8f659f1f35a7a25de469725417ab43 421bdd203eab09e560f4919715fa4cc4497e406f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jan 30 11:47:52 2008 +1100

    Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-abartlet

commit 81a0a7967b8f659f1f35a7a25de469725417ab43
Merge: f0a4db22e58d393be5b28f767ee6d0abfc8f11dc f5ea5de797f4fe35baf4f2bcd2913902c6703f44
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jan 29 10:59:14 2008 +1100

    Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-abartlet

commit f0a4db22e58d393be5b28f767ee6d0abfc8f11dc
Merge: 74220ca244865f97825cabdbc8aa899e71c25c7d 079200b824de6dd8c7de3e5b76ed1805fde02965
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Jan 28 16:39:03 2008 +1100

    Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-abartlet

commit 74220ca244865f97825cabdbc8aa899e71c25c7d
Merge: 8831a5c7935f7e2181252b7b6561541b8c8db679 b99b604a5f8b7eb98a6285145188c0b94946df78
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jan 22 10:53:14 2008 +1100

    Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-abartlet

commit 8831a5c7935f7e2181252b7b6561541b8c8db679
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jan 16 09:45:29 2008 +1100

    Allow the 'extra' objectclass added to objectClass attributes by
    ldb_map to be modified (or omitted).
    
    This should allow the current abuse of extensibleObject to be replaced
    by a normal objectClass, possibly samba4TOP
    
    Andrew Bartlett

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

Summary of changes:
 source/cldap_server/cldap_server.c                 |    2 +-
 source/cluster/cluster.c                           |    6 +-
 source/cluster/cluster.h                           |    2 +-
 source/cluster/cluster_private.h                   |    2 +-
 source/cluster/ctdb/ctdb_cluster.c                 |    5 +-
 source/cluster/local.c                             |    5 +-
 source/dsdb/repl/drepl_service.c                   |    2 +-
 source/kdc/kdc.c                                   |    2 +-
 source/ldap_server/ldap_server.c                   |    2 +-
 source/lib/messaging/messaging.c                   |    8 +-
 source/lib/messaging/tests/irpc.c                  |   10 +-
 source/lib/messaging/tests/messaging.c             |   10 +-
 source/librpc/idl/misc.idl                         |    3 +-
 source/nbt_server/nbt_server.c                     |    2 +-
 source/param/loadparm.c                            |    2 +
 source/rpc_server/service_rpc.c                    |    2 +-
 source/scripting/ejs/smbcalls_rpc.c                |    2 +-
 source/smb_server/smb_server.c                     |    2 +-
 source/smbd/process_model.h                        |    3 +-
 source/smbd/process_model.mk                       |   10 ++
 .../smbd/{process_standard.c => process_prefork.c} |  170 +++++++++-----------
 source/smbd/process_single.c                       |   31 +++-
 source/smbd/process_standard.c                     |   11 +-
 source/smbd/process_thread.c                       |    7 +-
 source/smbd/service_stream.c                       |   16 ++-
 source/smbd/service_task.c                         |    3 +-
 source/web_server/web_server.c                     |    2 +-
 source/winbind/wb_server.c                         |    2 +-
 source/wrepl_server/wrepl_server.c                 |    2 +-
 29 files changed, 178 insertions(+), 148 deletions(-)
 copy source/smbd/{process_standard.c => process_prefork.c} (51%)


Changeset truncated at 500 lines:

diff --git a/source/cldap_server/cldap_server.c b/source/cldap_server/cldap_server.c
index d686371..944d679 100644
--- a/source/cldap_server/cldap_server.c
+++ b/source/cldap_server/cldap_server.c
@@ -209,7 +209,7 @@ static void cldapd_task_init(struct task_server *task)
  */
 static NTSTATUS cldapd_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
 {
-	return task_server_startup(event_ctx, lp_ctx, model_ops, cldapd_task_init);
+	return task_server_startup(event_ctx, lp_ctx, "cldap", model_ops, cldapd_task_init);
 }
 
 
diff --git a/source/cluster/cluster.c b/source/cluster/cluster.c
index 6bac1dc..cc61974 100644
--- a/source/cluster/cluster.c
+++ b/source/cluster/cluster.c
@@ -47,12 +47,12 @@ static void cluster_init(void)
 }
 
 /*
-  server a server_id for the local node
+  create a server_id for the local node
 */
-struct server_id cluster_id(uint32_t id)
+struct server_id cluster_id(uint64_t id, uint32_t id2)
 {
 	cluster_init();
-	return ops->cluster_id(ops, id);
+	return ops->cluster_id(ops, id, id2);
 }
 
 
diff --git a/source/cluster/cluster.h b/source/cluster/cluster.h
index 7cd3128..203aef4 100644
--- a/source/cluster/cluster.h
+++ b/source/cluster/cluster.h
@@ -36,7 +36,7 @@ struct messaging_context;
 typedef void (*cluster_message_fn_t)(struct messaging_context *, DATA_BLOB);
 
 /* prototypes */
-struct server_id cluster_id(uint32_t id);
+struct server_id cluster_id(uint64_t id, uint32_t id2);
 const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id);
 struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags);
 void *cluster_backend_handle(void);
diff --git a/source/cluster/cluster_private.h b/source/cluster/cluster_private.h
index 1c895b8..79394b4 100644
--- a/source/cluster/cluster_private.h
+++ b/source/cluster/cluster_private.h
@@ -23,7 +23,7 @@
 #define _CLUSTER_PRIVATE_H_
 
 struct cluster_ops {
-	struct server_id (*cluster_id)(struct cluster_ops *ops, uint32_t id);
+	struct server_id (*cluster_id)(struct cluster_ops *ops, uint64_t id, uint32_t id2);
 	const char *(*cluster_id_string)(struct cluster_ops *ops, 
 					 TALLOC_CTX *, struct server_id );
 	struct tdb_wrap *(*cluster_tdb_tmp_open)(struct cluster_ops *,
diff --git a/source/cluster/ctdb/ctdb_cluster.c b/source/cluster/ctdb/ctdb_cluster.c
index 53df1e9..ce295c4 100644
--- a/source/cluster/ctdb/ctdb_cluster.c
+++ b/source/cluster/ctdb/ctdb_cluster.c
@@ -52,13 +52,14 @@ struct cluster_state {
 /*
   return a server_id for a ctdb node
 */
-static struct server_id ctdb_id(struct cluster_ops *ops, uint32_t id)
+static struct server_id ctdb_id(struct cluster_ops *ops, uint64_t id, uint32_t id2)
 {
 	struct cluster_state *state = (struct cluster_state *)ops->private;
 	struct ctdb_context *ctdb = state->ctdb;
 	struct server_id server_id;
 	server_id.node = ctdb_get_vnn(ctdb);
 	server_id.id = id;
+	server_id.id2 = id2;
 	return server_id;
 }
 
@@ -69,7 +70,7 @@ static struct server_id ctdb_id(struct cluster_ops *ops, uint32_t id)
 static const char *ctdb_id_string(struct cluster_ops *ops, 
 				  TALLOC_CTX *mem_ctx, struct server_id id)
 {
-	return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id);
+	return talloc_asprintf(mem_ctx, "%u.%llu.%u", id.node, (unsigned long long)id.id, id.id2);
 }
 
 /*
diff --git a/source/cluster/local.c b/source/cluster/local.c
index 539e47d..9663692 100644
--- a/source/cluster/local.c
+++ b/source/cluster/local.c
@@ -31,11 +31,12 @@
 /*
   server a server_id for the local node
 */
-static struct server_id local_id(struct cluster_ops *ops, uint32_t id)
+static struct server_id local_id(struct cluster_ops *ops, uint64_t id, uint32_t id2)
 {
 	struct server_id server_id;
 	ZERO_STRUCT(server_id);
 	server_id.id = id;
+	server_id.id2 = id2;
 	return server_id;
 }
 
@@ -46,7 +47,7 @@ static struct server_id local_id(struct cluster_ops *ops, uint32_t id)
 static const char *local_id_string(struct cluster_ops *ops,
 				   TALLOC_CTX *mem_ctx, struct server_id id)
 {
-	return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id);
+	return talloc_asprintf(mem_ctx, "%u.%llu.%u", id.node, (unsigned long long)id.id, id.id2);
 }
 
 
diff --git a/source/dsdb/repl/drepl_service.c b/source/dsdb/repl/drepl_service.c
index e212407..246309e 100644
--- a/source/dsdb/repl/drepl_service.c
+++ b/source/dsdb/repl/drepl_service.c
@@ -185,7 +185,7 @@ static void dreplsrv_task_init(struct task_server *task)
  */
 static NTSTATUS dreplsrv_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
 {
-	return task_server_startup(event_ctx, lp_ctx, model_ops, dreplsrv_task_init);
+	return task_server_startup(event_ctx, lp_ctx, "drepl", model_ops, dreplsrv_task_init);
 }
 
 /*
diff --git a/source/kdc/kdc.c b/source/kdc/kdc.c
index 04e7ddd..d820f0a 100644
--- a/source/kdc/kdc.c
+++ b/source/kdc/kdc.c
@@ -667,7 +667,7 @@ static NTSTATUS kdc_init(struct event_context *event_ctx,
 			 struct loadparm_context *lp_ctx,
 			 const struct model_ops *model_ops)
 {	
-	return task_server_startup(event_ctx, lp_ctx, model_ops, kdc_task_init);
+	return task_server_startup(event_ctx, lp_ctx, "kdc", model_ops, kdc_task_init);
 }
 
 /* called at smbd startup - register ourselves as a server service */
diff --git a/source/ldap_server/ldap_server.c b/source/ldap_server/ldap_server.c
index 8380775..f9c763e 100644
--- a/source/ldap_server/ldap_server.c
+++ b/source/ldap_server/ldap_server.c
@@ -584,7 +584,7 @@ static NTSTATUS ldapsrv_init(struct event_context *event_context,
 			     struct loadparm_context *lp_ctx,
 			     const struct model_ops *model_ops)
 {	
-	return task_server_startup(event_context, lp_ctx, model_ops, 
+	return task_server_startup(event_context, lp_ctx, "ldap", model_ops, 
 				   ldapsrv_task_init);
 }
 
diff --git a/source/lib/messaging/messaging.c b/source/lib/messaging/messaging.c
index 811d5a8..9cb10f9 100644
--- a/source/lib/messaging/messaging.c
+++ b/source/lib/messaging/messaging.c
@@ -263,8 +263,10 @@ static void messaging_send_handler(struct messaging_context *msg)
 		}
 		rec->retries = 0;
 		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(1,("messaging: Lost message from %u to %u of type %u - %s\n", 
-				 rec->header->from.id, rec->header->to.id, rec->header->msg_type, 
+			DEBUG(1,("messaging: Lost message from %s to %s of type %u - %s\n", 
+				 cluster_id_string(debug_ctx(), rec->header->from), 
+				 cluster_id_string(debug_ctx(), rec->header->to), 
+				 rec->header->msg_type, 
 				 nt_errstr(status)));
 		}
 		DLIST_REMOVE(msg->pending, rec);
@@ -1051,7 +1053,7 @@ struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx,
 	for (i=0;i<count;i++) {
 		ret[i] = ((struct server_id *)rec.dptr)[i];
 	}
-	ret[i] = cluster_id(0);
+	ret[i] = cluster_id(0, 0);
 	free(rec.dptr);
 	tdb_unlock_bystring(t->tdb, name);
 	talloc_free(t);
diff --git a/source/lib/messaging/tests/irpc.c b/source/lib/messaging/tests/irpc.c
index a2995fc..d9b0548 100644
--- a/source/lib/messaging/tests/irpc.c
+++ b/source/lib/messaging/tests/irpc.c
@@ -93,7 +93,7 @@ static bool test_addone(struct torture_context *test, const void *_data,
 	r.in.in_data = value;
 
 	test_debug = true;
-	status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2), 
+	status = IRPC_CALL(data->msg_ctx1, cluster_id(0, MSG_ID2), 
 			   rpcecho, ECHO_ADDONE, &r, test);
 	test_debug = false;
 	torture_assert_ntstatus_ok(test, status, "AddOne failed");
@@ -122,7 +122,7 @@ static bool test_echodata(struct torture_context *tctx,
 	r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
 	r.in.len = strlen((char *)r.in.in_data);
 
-	status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2), 
+	status = IRPC_CALL(data->msg_ctx1, cluster_id(0, MSG_ID2), 
 			   rpcecho, ECHO_ECHODATA, &r, 
 			   mem_ctx);
 	torture_assert_ntstatus_ok(tctx, status, "EchoData failed");
@@ -180,7 +180,7 @@ static bool test_speed(struct torture_context *tctx,
 	while (timeval_elapsed(&tv) < timelimit) {
 		struct irpc_request *irpc;
 
-		irpc = IRPC_CALL_SEND(data->msg_ctx1, cluster_id(MSG_ID2), 
+		irpc = IRPC_CALL_SEND(data->msg_ctx1, cluster_id(0, MSG_ID2), 
 				      rpcecho, ECHO_ADDONE, 
 				      &r, mem_ctx);
 		torture_assert(tctx, irpc != NULL, "AddOne send failed");
@@ -221,7 +221,7 @@ static bool irpc_setup(struct torture_context *tctx, void **_data)
 	torture_assert(tctx, data->msg_ctx1 = 
 		       messaging_init(tctx, 
 				      lp_messaging_path(tctx, tctx->lp_ctx), 
-				      cluster_id(MSG_ID1),
+				      cluster_id(0, MSG_ID1),
 				      lp_iconv_convenience(tctx->lp_ctx),
 				      data->ev),
 		       "Failed to init first messaging context");
@@ -229,7 +229,7 @@ static bool irpc_setup(struct torture_context *tctx, void **_data)
 	torture_assert(tctx, data->msg_ctx2 = 
 		       messaging_init(tctx, 
 				      lp_messaging_path(tctx, tctx->lp_ctx),
-				      cluster_id(MSG_ID2), 
+				      cluster_id(0, MSG_ID2), 
 				      lp_iconv_convenience(tctx->lp_ctx),
 				      data->ev),
 		       "Failed to init second messaging context");
diff --git a/source/lib/messaging/tests/messaging.c b/source/lib/messaging/tests/messaging.c
index 0df04bc..45b5735 100644
--- a/source/lib/messaging/tests/messaging.c
+++ b/source/lib/messaging/tests/messaging.c
@@ -73,7 +73,7 @@ static bool test_ping_speed(struct torture_context *tctx)
 
 	msg_server_ctx = messaging_init(tctx, 
 					lp_messaging_path(tctx, tctx->lp_ctx), 
-					cluster_id(1), 
+					cluster_id(0, 1), 
 				        lp_iconv_convenience(tctx->lp_ctx),
 					ev);
 	
@@ -84,7 +84,7 @@ static bool test_ping_speed(struct torture_context *tctx)
 
 	msg_client_ctx = messaging_init(tctx, 
 					lp_messaging_path(tctx, tctx->lp_ctx), 
-					cluster_id(2), 
+					cluster_id(0, 2), 
 				        lp_iconv_convenience(tctx->lp_ctx),
 					ev);
 
@@ -103,8 +103,8 @@ static bool test_ping_speed(struct torture_context *tctx)
 		data.data = discard_const_p(uint8_t, "testing");
 		data.length = strlen((const char *)data.data);
 
-		status1 = messaging_send(msg_client_ctx, cluster_id(1), msg_ping, &data);
-		status2 = messaging_send(msg_client_ctx, cluster_id(1), msg_ping, NULL);
+		status1 = messaging_send(msg_client_ctx, cluster_id(0, 1), msg_ping, &data);
+		status2 = messaging_send(msg_client_ctx, cluster_id(0, 1), msg_ping, NULL);
 
 		torture_assert_ntstatus_ok(tctx, status1, "msg1 failed");
 		ping_count++;
@@ -124,7 +124,7 @@ static bool test_ping_speed(struct torture_context *tctx)
 	}
 
 	torture_comment(tctx, "sending exit\n");
-	messaging_send(msg_client_ctx, cluster_id(1), msg_exit, NULL);
+	messaging_send(msg_client_ctx, cluster_id(0, 1), msg_exit, NULL);
 
 	torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed");
 
diff --git a/source/librpc/idl/misc.idl b/source/librpc/idl/misc.idl
index 0861758..8331977 100644
--- a/source/librpc/idl/misc.idl
+++ b/source/librpc/idl/misc.idl
@@ -51,7 +51,8 @@ interface misc
 
 	/* id used to identify a endpoint, possibly in a cluster */
 	typedef [public] struct {
-		uint32 id;
+		hyper id;
+		uint32 id2;
 		uint32 node;
 	} server_id;
 }
diff --git a/source/nbt_server/nbt_server.c b/source/nbt_server/nbt_server.c
index 1718ef7..bcdc63e 100644
--- a/source/nbt_server/nbt_server.c
+++ b/source/nbt_server/nbt_server.c
@@ -93,7 +93,7 @@ static void nbtd_task_init(struct task_server *task)
  */
 static NTSTATUS nbtd_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
 {
-	return task_server_startup(event_ctx, lp_ctx, 
+	return task_server_startup(event_ctx, lp_ctx, "nbt",
 				   model_ops, nbtd_task_init);
 }
 
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 2b7b9dd..9ec5a59 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -2408,6 +2408,8 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 	lp_do_global_parameter_var(lp_ctx, "setup directory", "%s", 
 				   dyn_SETUPDIR);
 
+	lp_do_global_parameter(lp_ctx, "prefork children:smb", "4");
+
 	for (i = 0; parm_table[i].label; i++) {
 		if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
 			lp_ctx->flags[i] |= FLAG_DEFAULT;
diff --git a/source/rpc_server/service_rpc.c b/source/rpc_server/service_rpc.c
index 4691613..855e120 100644
--- a/source/rpc_server/service_rpc.c
+++ b/source/rpc_server/service_rpc.c
@@ -465,7 +465,7 @@ static NTSTATUS dcesrv_init(struct event_context *event_context,
 			    struct loadparm_context *lp_ctx,
 			    const struct model_ops *model_ops)
 {	
-	return task_server_startup(event_context, lp_ctx, 
+	return task_server_startup(event_context, lp_ctx, "rpc",
 				   model_ops, dcesrv_task_init);
 }
 
diff --git a/source/scripting/ejs/smbcalls_rpc.c b/source/scripting/ejs/smbcalls_rpc.c
index 2bfc8b5..44cfa16 100644
--- a/source/scripting/ejs/smbcalls_rpc.c
+++ b/source/scripting/ejs/smbcalls_rpc.c
@@ -80,7 +80,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
 	for (i=0;i<10000;i++) {
 		p->msg_ctx = messaging_init(p, 
 					    lp_messaging_path(p, global_loadparm),
-					    cluster_id(EJS_ID_BASE + i), 
+					    cluster_id(EJS_ID_BASE, i), 
 				            lp_iconv_convenience(global_loadparm),
 					    ev);
 		if (p->msg_ctx) break;
diff --git a/source/smb_server/smb_server.c b/source/smb_server/smb_server.c
index cbff585..866ae26 100644
--- a/source/smb_server/smb_server.c
+++ b/source/smb_server/smb_server.c
@@ -258,7 +258,7 @@ static NTSTATUS smbsrv_init(struct event_context *event_context,
 			    struct loadparm_context *lp_ctx,
 			    const struct model_ops *model_ops)
 {	
-	return task_server_startup(event_context, lp_ctx, 
+	return task_server_startup(event_context, lp_ctx, "smb",
 				   model_ops, smbsrv_task_init);
 }
 
diff --git a/source/smbd/process_model.h b/source/smbd/process_model.h
index c2a5c9e..796c8ee 100644
--- a/source/smbd/process_model.h
+++ b/source/smbd/process_model.h
@@ -25,7 +25,7 @@
 #define __PROCESS_MODEL_H__
 
 #include "lib/socket/socket.h"
-#include "smbd/service_task.h"
+#include "smbd/service.h"
 
 /* modules can use the following to determine if the interface has changed
  * please increment the version number after each interface change
@@ -56,6 +56,7 @@ struct model_ops {
 	/* function to create a task */
 	void (*new_task)(struct event_context *, 
 			 struct loadparm_context *lp_ctx, 
+			 const char *service_name,
 			 void (*)(struct event_context *, 
 				  struct loadparm_context *, struct server_id, 
 				  void *),
diff --git a/source/smbd/process_model.mk b/source/smbd/process_model.mk
index d6b7698..5201a2e 100644
--- a/source/smbd/process_model.mk
+++ b/source/smbd/process_model.mk
@@ -32,6 +32,16 @@ PRIVATE_DEPENDENCIES = PTHREAD
 # End MODULE process_model_thread
 ################################################
 
+################################################
+# Start MODULE process_model_prefork
+[MODULE::process_model_prefork]
+INIT_FUNCTION = process_model_prefork_init 
+SUBSYSTEM = process_model
+OBJ_FILES = \
+		process_prefork.o
+# End MODULE process_model_thread
+################################################
+
 [SUBSYSTEM::process_model]
 PRIVATE_PROTO_HEADER = process_model_proto.h
 OBJ_FILES = \
diff --git a/source/smbd/process_standard.c b/source/smbd/process_prefork.c
similarity index 51%
copy from source/smbd/process_standard.c
copy to source/smbd/process_prefork.c
index c088ea3..9f975b4 100644
--- a/source/smbd/process_standard.c
+++ b/source/smbd/process_prefork.c
@@ -1,11 +1,13 @@
 /* 
    Unix SMB/CIFS implementation.
 
-   process model: standard (1 process per client connection)
+   process model: prefork (n client connections per process)
 
    Copyright (C) Andrew Tridgell 1992-2005
    Copyright (C) James J Myers 2003 <myersjj at samba.org>
    Copyright (C) Stefan (metze) Metzmacher 2004
+   Copyright (C) Andrew Bartlett 2008 <abartlet at samba.org>
+   Copyright (C) David Disseldorp 2008 <ddiss at sgi.com>
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -47,7 +49,7 @@ static int none_setproctitle(const char *fmt, ...)
 /*
   called when the process model is selected
 */
-static void standard_model_init(struct event_context *ev)
+static void prefork_model_init(struct event_context *ev)
 {
 	signal(SIGCHLD, SIG_IGN);
 }
@@ -55,7 +57,7 @@ static void standard_model_init(struct event_context *ev)
 /*
   called when a listening socket becomes readable. 
 */
-static void standard_accept_connection(struct event_context *ev, 
+static void prefork_accept_connection(struct event_context *ev, 
 				       struct loadparm_context *lp_ctx,
 				       struct socket_context *sock, 
 				       void (*new_conn)(struct event_context *,
@@ -65,90 +67,32 @@ static void standard_accept_connection(struct event_context *ev,
 {
 	NTSTATUS status;
 	struct socket_context *sock2;
-	pid_t pid;
-	struct event_context *ev2;
-	struct socket_address *c, *s;
+	pid_t pid = getpid();
 
 	/* accept an incoming connection. */
 	status = socket_accept(sock, &sock2);
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("standard_accept_connection: accept: %s\n",
-			 nt_errstr(status)));
-		/* this looks strange, but is correct. We need to throttle things until
-		   the system clears enough resources to handle this new socket */
-		sleep(1);
-		return;
-	}
-
-	pid = fork();
-
-	if (pid != 0) {
-		/* parent or error code ... */
-		talloc_free(sock2);
-		/* go back to the event loop */
 		return;
 	}
 
-	pid = getpid();
-
-	/* This is now the child code. We need a completely new event_context to work with */
-	ev2 = event_context_init(NULL);
-
-	/* the service has given us a private pointer that
-	   encapsulates the context it needs for this new connection -
-	   everything else will be freed */
-	talloc_steal(ev2, private);
-	talloc_steal(private, sock2);
-
-	/* this will free all the listening sockets and all state that
-	   is not associated with this new connection */
-	talloc_free(sock);
-	talloc_free(ev);
-
-	/* we don't care if the dup fails, as its only a select()
-	   speed optimisation */
-	socket_dup(sock2);
-			
-	/* tdb needs special fork handling */
-	if (tdb_reopen_all(1) == -1) {
-		DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
-	}
-
-	/* Ensure that the forked children do not expose identical random streams */
-	set_need_random_reseed();
-
-	/* setup the process title */
-	c = socket_get_peer_addr(sock2, ev2);
-	s = socket_get_my_addr(sock2, ev2);
-	if (s && c) {
-		setproctitle("conn c[%s:%u] s[%s:%u] server_id[%d]",
-			     c->addr, c->port, s->addr, s->port, pid);
-	}
-	talloc_free(c);
-	talloc_free(s);
-
-	/* setup this new connection */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list