svn commit: samba r20679 - in branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules: .

metze at samba.org metze at samba.org
Thu Jan 11 09:38:22 GMT 2007


Author: metze
Date: 2007-01-11 09:38:21 +0000 (Thu, 11 Jan 2007)
New Revision: 20679

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20679

Log:
make the init_handle stuff a bit easier and get rid of really ugly talloc_get_type()
usage

simo: if you change more modules, please include also this change

metze
Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/partition.c


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/partition.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/partition.c	2007-01-11 09:35:26 UTC (rev 20678)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/partition.c	2007-01-11 09:38:21 UTC (rev 20679)
@@ -50,6 +50,7 @@
 
 struct partition_context {
 	struct ldb_module *module;
+	struct ldb_handle *handle;
 	struct ldb_request *orig_req;
 
 	struct ldb_request **down_req;
@@ -57,7 +58,7 @@
 	int finished_requests;
 };
 
-static struct ldb_handle *partition_init_handle(struct ldb_request *req, struct ldb_module *module)
+static struct partition_context *partition_init_handle(struct ldb_request *req, struct ldb_module *module)
 {
 	struct partition_context *ac;
 	struct ldb_handle *h;
@@ -77,12 +78,15 @@
 		return NULL;
 	}
 
-	h->private_data = (void *)ac;
+	h->private_data	= ac;
 
 	ac->module = module;
+	ac->handle = h;
 	ac->orig_req = req;
 
-	return h;
+	req->handle = h;
+
+	return ac;
 }
 
 struct ldb_module *make_module_for_next_request(TALLOC_CTX *mem_ctx, 
@@ -264,18 +268,13 @@
 	for (i=0; data->replicate && data->replicate[i]; i++) {
 		if (ldb_dn_compare(data->replicate[i], 
 				   dn) == 0) {
-			struct ldb_handle *h;
 			struct partition_context *ac;
 			
-			h = partition_init_handle(req, module);
-			if (!h) {
+			ac = partition_init_handle(req, module);
+			if (!ac) {
 				return LDB_ERR_OPERATIONS_ERROR;
 			}
-			/* return our own handle to deal with this call */
-			req->handle = h;
 			
-			ac = talloc_get_type(h->private_data, struct partition_context);
-			
 			return partition_send_all(module, ac, req);
 		}
 	}
@@ -302,18 +301,13 @@
 	 * partitions (for 'invisible' partition behaviour */
 	if (ldb_get_opaque(module->ldb, "global_catalog")) {
 		int ret, i;
-		struct ldb_handle *h;
 		struct partition_context *ac;
 		
-		h = partition_init_handle(req, module);
-		if (!h) {
+		ac = partition_init_handle(req, module);
+		if (!ac) {
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
-		/* return our own handle to deal with this call */
-		req->handle = h;
-		
-		ac = talloc_get_type(h->private_data, struct partition_context);
-		
+
 		/* Search from the base DN */
 		if (!req->op.search.base || ldb_dn_is_null(req->op.search.base)) {
 			return partition_send_all(module, ac, req);
@@ -330,7 +324,7 @@
 
 		/* Perhaps we didn't match any partitions.  Try the main partition, only */
 		if (ac->num_requests == 0) {
-			talloc_free(h);
+			talloc_free(ac);
 			return ldb_next_request(module, req);
 		}
 		
@@ -586,7 +580,6 @@
 /* extended */
 static int partition_extended(struct ldb_module *module, struct ldb_request *req)
 {
-	struct ldb_handle *h;
 	struct partition_context *ac;
 
 	if (strcmp(req->op.extended.oid, DSDB_EXTENDED_REPLICATED_OBJECTS_OID) == 0) {
@@ -598,15 +591,11 @@
 	 * we need to send it to all partitions
 	 */
 
-	h = partition_init_handle(req, module);
-	if (!h) {
+	ac = partition_init_handle(req, module);
+	if (!ac) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
-	/* return our own handle to deal with this call */
-	req->handle = h;
 			
-	ac = talloc_get_type(h->private_data, struct partition_context);
-			
 	return partition_send_all(module, ac, req);
 }
 



More information about the samba-cvs mailing list