diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-09-13 12:46:03 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:08 -0500 |
commit | 45f760973d9b5c0663608e779eb337c0648e9313 (patch) | |
tree | 8021224e493f613ec4107f531519a44059cff048 /source4 | |
parent | 6bfea6335620083f3fd8b47a297c7c0140fb33c1 (diff) | |
download | samba-45f760973d9b5c0663608e779eb337c0648e9313.tar.gz samba-45f760973d9b5c0663608e779eb337c0648e9313.tar.bz2 samba-45f760973d9b5c0663608e779eb337c0648e9313.zip |
r10200: 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().
(This used to be commit 9cc000d868e1257ef6429f6f6f1f9d3c28ca330f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/socket/connect.c | 5 | ||||
-rw-r--r-- | source4/libcli/composite/composite.c | 24 | ||||
-rw-r--r-- | source4/libcli/composite/connect.c | 14 | ||||
-rw-r--r-- | source4/libcli/resolve/resolve.c | 9 |
4 files changed, 36 insertions, 16 deletions
diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c index bb4d7cc843..04902442e3 100644 --- a/source4/lib/socket/connect.c +++ b/source4/lib/socket/connect.c @@ -36,11 +36,6 @@ static NTSTATUS connect_resolve(TALLOC_CTX *mem_ctx, const char *address, { 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; diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 2b8ddea897..f04309bbfb 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -44,3 +44,27 @@ NTSTATUS composite_wait(struct composite_context *c) } +/* + 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); +} diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c index 4d35f5c73a..a5ce5308e5 100644 --- a/source4/libcli/composite/connect.c +++ b/source4/libcli/composite/connect.c @@ -352,17 +352,9 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec 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; diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index 733eddf643..d62890434b 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -144,6 +144,15 @@ struct composite_context *resolve_name_send(struct nbt_name *name, struct event_ 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; |