svn commit: samba r19645 - in branches/SAMBA_4_0/source: libcli/resolve torture/local

metze at samba.org metze at samba.org
Thu Nov 9 01:11:48 GMT 2006


Author: metze
Date: 2006-11-09 01:11:45 +0000 (Thu, 09 Nov 2006)
New Revision: 19645

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

Log:
don't pass NULL as mem_ctx...

metze
Modified:
   branches/SAMBA_4_0/source/libcli/resolve/bcast.c
   branches/SAMBA_4_0/source/libcli/resolve/host.c
   branches/SAMBA_4_0/source/libcli/resolve/nbtlist.c
   branches/SAMBA_4_0/source/libcli/resolve/resolve.c
   branches/SAMBA_4_0/source/libcli/resolve/wins.c
   branches/SAMBA_4_0/source/torture/local/resolve.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/resolve/bcast.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/bcast.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/libcli/resolve/bcast.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -28,15 +28,16 @@
 /*
   broadcast name resolution method - async send
  */
-struct composite_context *resolve_name_bcast_send(struct nbt_name *name, 
-						 struct event_context *event_ctx)
+struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx, 
+						  struct event_context *event_ctx,
+						  struct nbt_name *name)
 {
 	int num_interfaces = iface_count();
 	const char **address_list;
 	struct composite_context *c;
 	int i, count=0;
 
-	address_list = talloc_array(NULL, const char *, num_interfaces+1);
+	address_list = talloc_array(mem_ctx, const char *, num_interfaces+1);
 	if (address_list == NULL) return NULL;
 
 	for (i=0;i<num_interfaces;i++) {
@@ -51,7 +52,7 @@
 	}
 	address_list[count] = NULL;
 
-	c = resolve_name_nbtlist_send(name, event_ctx, address_list, True, False);
+	c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, True, False);
 	talloc_free(address_list);
 
 	return c;	
@@ -73,7 +74,7 @@
 			    TALLOC_CTX *mem_ctx,
 			    const char **reply_addr)
 {
-	struct composite_context *c = resolve_name_bcast_send(name, NULL);
+	struct composite_context *c = resolve_name_bcast_send(mem_ctx, NULL, name);
 	return resolve_name_bcast_recv(c, mem_ctx, reply_addr);
 }
 

Modified: branches/SAMBA_4_0/source/libcli/resolve/host.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/host.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/libcli/resolve/host.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -77,6 +77,7 @@
 	if (address != NULL) {
 		write(fd, address, strlen(address)+1);
 	}
+	close(fd);
 }
 
 /*
@@ -121,15 +122,16 @@
 /*
   gethostbyname name resolution method - async send
  */
-struct composite_context *resolve_name_host_send(struct nbt_name *name, 
-						struct event_context *event_ctx)
+struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
+						 struct event_context *event_ctx,
+						 struct nbt_name *name)
 {
 	struct composite_context *c;
 	struct host_state *state;
 	int fd[2] = { -1, -1 };
 	int ret;
 
-	c = composite_create(event_ctx, event_ctx);
+	c = composite_create(mem_ctx, event_ctx);
 	if (c == NULL) return NULL;
 
 	c->event_ctx = talloc_reference(c, event_ctx);
@@ -172,6 +174,7 @@
 		return c;
 	}
 
+
 	if (state->child == 0) {
 		close(fd[0]);
 		run_child(c, fd[1]);
@@ -189,7 +192,7 @@
   gethostbyname name resolution method - recv side
 */
 NTSTATUS resolve_name_host_recv(struct composite_context *c, 
-				 TALLOC_CTX *mem_ctx, const char **reply_addr)
+				TALLOC_CTX *mem_ctx, const char **reply_addr)
 {
 	NTSTATUS status;
 
@@ -211,7 +214,7 @@
 			    TALLOC_CTX *mem_ctx,
 			    const char **reply_addr)
 {
-	struct composite_context *c = resolve_name_host_send(name, NULL);
+	struct composite_context *c = resolve_name_host_send(mem_ctx, NULL, name);
 	return resolve_name_host_recv(c, mem_ctx, reply_addr);
 }
 

Modified: branches/SAMBA_4_0/source/libcli/resolve/nbtlist.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/nbtlist.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/libcli/resolve/nbtlist.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -95,11 +95,12 @@
 /*
   nbtlist name resolution method - async send
  */
-struct composite_context *resolve_name_nbtlist_send(struct nbt_name *name, 
-						   struct event_context *event_ctx,
-						   const char **address_list,
-						   BOOL broadcast,
-						   BOOL wins_lookup)
+struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
+						    struct event_context *event_ctx,
+						    struct nbt_name *name, 
+						    const char **address_list,
+						    BOOL broadcast,
+						    BOOL wins_lookup)
 {
 	struct composite_context *c;
 	struct nbtlist_state *state;
@@ -186,8 +187,8 @@
 			      BOOL broadcast, BOOL wins_lookup,
 			      const char **reply_addr)
 {
-	struct composite_context *c = resolve_name_nbtlist_send(name, NULL, address_list, 
-							       broadcast, wins_lookup);
+	struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, name, address_list, 
+							        broadcast, wins_lookup);
 	return resolve_name_nbtlist_recv(c, mem_ctx, reply_addr);
 }
 

Modified: branches/SAMBA_4_0/source/libcli/resolve/resolve.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/resolve.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/libcli/resolve/resolve.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -38,7 +38,7 @@
 /* pointers to the resolver backends */
 static const struct resolve_method {
 	const char *name;
-	struct composite_context *(*send_fn)(struct nbt_name *, struct event_context *);
+	struct composite_context *(*send_fn)(TALLOC_CTX *mem_ctx, struct event_context *, struct nbt_name *);
 	NTSTATUS (*recv_fn)(struct composite_context *, TALLOC_CTX *, const char **);
 
 } resolve_methods[] = {
@@ -101,7 +101,7 @@
 	do {
 		const struct resolve_method *method = find_method(state->methods[0]);
 		if (method) {
-			creq = method->send_fn(&state->name, c->event_ctx);
+			creq = method->send_fn(c, c->event_ctx, &state->name);
 		}
 		if (creq == NULL && state->methods[0]) state->methods++;
 

Modified: branches/SAMBA_4_0/source/libcli/resolve/wins.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/wins.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/libcli/resolve/wins.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -27,19 +27,20 @@
 /*
   wins name resolution method - async send
  */
-struct composite_context *resolve_name_wins_send(struct nbt_name *name, 
-						 struct event_context *event_ctx)
+struct composite_context *resolve_name_wins_send(TALLOC_CTX *mem_ctx, 
+						 struct event_context *event_ctx,
+						 struct nbt_name *name)
 {
 	const char **address_list = lp_wins_server_list();
 	if (address_list == NULL) return NULL;
-	return resolve_name_nbtlist_send(name, event_ctx, address_list, False, True);
+	return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, False, True);
 }
 
 /*
   wins name resolution method - recv side
  */
 NTSTATUS resolve_name_wins_recv(struct composite_context *c, 
-				 TALLOC_CTX *mem_ctx, const char **reply_addr)
+				TALLOC_CTX *mem_ctx, const char **reply_addr)
 {
 	return resolve_name_nbtlist_recv(c, mem_ctx, reply_addr);
 }
@@ -51,7 +52,7 @@
 			    TALLOC_CTX *mem_ctx,
 			    const char **reply_addr)
 {
-	struct composite_context *c = resolve_name_wins_send(name, NULL);
+	struct composite_context *c = resolve_name_wins_send(mem_ctx, NULL, name);
 	return resolve_name_wins_recv(c, mem_ctx, reply_addr);
 }
 

Modified: branches/SAMBA_4_0/source/torture/local/resolve.c
===================================================================
--- branches/SAMBA_4_0/source/torture/local/resolve.c	2006-11-09 00:33:43 UTC (rev 19644)
+++ branches/SAMBA_4_0/source/torture/local/resolve.c	2006-11-09 01:11:45 UTC (rev 19645)
@@ -40,11 +40,11 @@
 	ZERO_STRUCT(n);
 	n.name = host;
 
-	torture_comment(tctx, "Testing async resolve of localhost for %d seconds\n",
-					timelimit);
+	torture_comment(tctx, "Testing async resolve of '%s' for %d seconds\n",
+			host, timelimit);
 	while (timeval_elapsed(&tv) < timelimit) {
 		const char *s;
-		struct composite_context *c = resolve_name_host_send(&n, ev);
+		struct composite_context *c = resolve_name_host_send(mem_ctx, ev, &n);
 		torture_assert(tctx, c != NULL, "resolve_name_host_send");
 		torture_assert_ntstatus_ok(tctx, resolve_name_host_recv(c, mem_ctx, &s),
 								   "async resolve failed");
@@ -52,7 +52,7 @@
 	}
 
 	torture_comment(tctx, "async rate of %.1f resolves/sec\n", 
-					count/timeval_elapsed(&tv));
+			count/timeval_elapsed(&tv));
 	return true;
 }
 
@@ -66,23 +66,22 @@
 	int count = 0;
 	const char *host = torture_setting_string(tctx, "host", NULL);
 
-	torture_comment(tctx, "Testing sync resolve of localhost for %d seconds\n", 
-				 timelimit);
+	torture_comment(tctx, "Testing sync resolve of '%s' for %d seconds\n", 
+			host, timelimit);
 	while (timeval_elapsed(&tv) < timelimit) {
 		sys_inet_ntoa(interpret_addr2(host));
 		count++;
 	}
 	
 	torture_comment(tctx, "sync rate of %.1f resolves/sec\n", 
-				 count/timeval_elapsed(&tv));
+			count/timeval_elapsed(&tv));
 	return true;
 }
 
 
 struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx)
 {
-	struct torture_suite *suite = torture_suite_create(mem_ctx,
-													   "RESOLVE");
+	struct torture_suite *suite = torture_suite_create(mem_ctx, "RESOLVE");
 
 	torture_suite_add_simple_test(suite, "async", test_async_resolve);
 	torture_suite_add_simple_test(suite, "sync", test_sync_resolve);



More information about the samba-cvs mailing list