svn commit: samba r10200 - in branches/SAMBA_4_0/source: lib/socket libcli/composite libcli/resolve

tridge at samba.org tridge at samba.org
Tue Sep 13 12:46:03 GMT 2005


Author: tridge
Date: 2005-09-13 12:46:03 +0000 (Tue, 13 Sep 2005)
New Revision: 10200

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

Log:
added a composite_trigger_done() call that allows a composite function
to cause an event to happen immediately. This allows metzes patch for
recognising IPs in resolve_name() to work, and also allows us to
remove some of the other code where we currently do specific checks
for is_ipaddress().

Modified:
   branches/SAMBA_4_0/source/lib/socket/connect.c
   branches/SAMBA_4_0/source/libcli/composite/composite.c
   branches/SAMBA_4_0/source/libcli/composite/connect.c
   branches/SAMBA_4_0/source/libcli/resolve/resolve.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/socket/connect.c
===================================================================
--- branches/SAMBA_4_0/source/lib/socket/connect.c	2005-09-13 12:44:33 UTC (rev 10199)
+++ branches/SAMBA_4_0/source/lib/socket/connect.c	2005-09-13 12:46:03 UTC (rev 10200)
@@ -36,11 +36,6 @@
 {
 	struct nbt_name name;
 
-	if (is_ipaddress(address) || strcasecmp("localhost", address) == 0) {
-		*ret_address = address;
-		return NT_STATUS_OK;
-	}
-
 	name.name = address;
 	name.scope = NULL;
 	name.type = NBT_NAME_CLIENT;

Modified: branches/SAMBA_4_0/source/libcli/composite/composite.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/composite.c	2005-09-13 12:44:33 UTC (rev 10199)
+++ branches/SAMBA_4_0/source/libcli/composite/composite.c	2005-09-13 12:46:03 UTC (rev 10200)
@@ -44,3 +44,27 @@
 }
 
 
+/* 
+   callback from composite_trigger_done() 
+*/
+static void composite_trigger(struct event_context *ev, struct timed_event *te,
+			      struct timeval t, void *ptr)
+{
+	struct composite_context *c = talloc_get_type(ptr, struct composite_context);
+	c->state = SMBCLI_REQUEST_DONE;
+	if (c->async.fn) {
+		c->async.fn(c);
+	}
+}
+
+
+/*
+  trigger an immediate 'done' event on a composite context
+  this is used when the composite code works out that the call
+  can be completed without waiting for any external event
+*/
+void composite_trigger_done(struct composite_context *c)
+{
+	/* a zero timeout means immediate */
+	event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c);
+}

Modified: branches/SAMBA_4_0/source/libcli/composite/connect.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/connect.c	2005-09-13 12:44:33 UTC (rev 10199)
+++ branches/SAMBA_4_0/source/libcli/composite/connect.c	2005-09-13 12:46:03 UTC (rev 10200)
@@ -352,17 +352,9 @@
 	c->event_ctx = talloc_reference(c, state->sock->event.ctx);
 	c->private = state;
 
-	/* if the destination is an IP address, then skip the name resolution part */
-	if (is_ipaddress(io->in.dest_host)) {
-		state->stage = CONNECT_SOCKET;
-		state->creq = smbcli_sock_connect_send(state->sock, io->in.dest_host, 
-						       state->io->in.port, 
-						       io->in.dest_host);
-	} else {
-		state->stage = CONNECT_RESOLVE;
-		make_nbt_name_server(&name, io->in.dest_host);
-		state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
-	}
+	state->stage = CONNECT_RESOLVE;
+	make_nbt_name_server(&name, io->in.dest_host);
+	state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
 
 	if (state->creq == NULL) goto failed;
 	state->creq->async.private = c;

Modified: branches/SAMBA_4_0/source/libcli/resolve/resolve.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/resolve/resolve.c	2005-09-13 12:44:33 UTC (rev 10199)
+++ branches/SAMBA_4_0/source/libcli/resolve/resolve.c	2005-09-13 12:46:03 UTC (rev 10200)
@@ -144,6 +144,15 @@
 		c->event_ctx = talloc_reference(c, event_ctx);
 	}
 
+	if (is_ipaddress(state->name.name) || 
+	    strcasecmp(state->name.name, "localhost") == 0) {
+		struct ipv4_addr ip = interpret_addr2(state->name.name);
+		state->reply_addr = talloc_strdup(state, sys_inet_ntoa(ip));
+		if (!state->reply_addr) goto failed;
+		composite_trigger_done(c);
+		return c;
+	}
+
 	state->req = setup_next_method(c);
 	if (state->req == NULL) goto failed;
 	



More information about the samba-cvs mailing list