From 9bc38ce65f1907230618b3edccafb1d33f753fe0 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Thu, 29 Sep 2005 22:37:15 +0000 Subject: r10636: Formatting for better readability. rafal (This used to be commit ef29863d999089c47140bd37731c60659a200421) --- source4/libcli/resolve/nbtlist.c | 18 ++++++++++++------ source4/libcli/resolve/resolve.c | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'source4/libcli/resolve') diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c index 4fb4ccbb20..f8fe5df9a1 100644 --- a/source4/libcli/resolve/nbtlist.c +++ b/source4/libcli/resolve/nbtlist.c @@ -51,6 +51,7 @@ static void nbtlist_handler(struct nbt_name_request *req) for (i=0;inum_queries;i++) { if (req == state->queries[i]) break; } + if (i == state->num_queries) { /* not for us?! */ c->status = NT_STATUS_INTERNAL_ERROR; @@ -61,15 +62,18 @@ static void nbtlist_handler(struct nbt_name_request *req) c->status = nbt_name_query_recv(req, state, &state->io_queries[i]); if (!NT_STATUS_IS_OK(c->status)) { c->state = COMPOSITE_STATE_ERROR; + } else { if (state->io_queries[i].out.num_addrs < 1) { c->state = COMPOSITE_STATE_ERROR; c->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; + } else { struct nbt_name_query *q = &state->io_queries[i]; c->state = COMPOSITE_STATE_DONE; /* favor a local address if possible */ state->reply_addr = NULL; + for (i=0;iout.num_addrs;i++) { if (iface_is_local(q->out.reply_addrs[i])) { state->reply_addr = talloc_steal(state, @@ -77,6 +81,7 @@ static void nbtlist_handler(struct nbt_name_request *req) break; } } + if (state->reply_addr == NULL) { state->reply_addr = talloc_steal(state, q->out.reply_addrs[0]); @@ -135,18 +140,19 @@ struct composite_context *resolve_name_nbtlist_send(struct nbt_name *name, if (!state->queries) goto failed; for (i=0;inum_queries;i++) { - state->io_queries[i].in.name = state->name; - state->io_queries[i].in.dest_addr = talloc_strdup(state->io_queries, address_list[i]); + state->io_queries[i].in.name = state->name; + state->io_queries[i].in.dest_addr = talloc_strdup(state->io_queries, address_list[i]); if (!state->io_queries[i].in.dest_addr) goto failed; - state->io_queries[i].in.broadcast = broadcast; + + state->io_queries[i].in.broadcast = broadcast; state->io_queries[i].in.wins_lookup = wins_lookup; - state->io_queries[i].in.timeout = lp_parm_int(-1, "nbt", "timeout", 1); + state->io_queries[i].in.timeout = lp_parm_int(-1, "nbt", "timeout", 1); + state->io_queries[i].in.retries = 2; - state->io_queries[i].in.retries = 2; state->queries[i] = nbt_name_query_send(state->nbtsock, &state->io_queries[i]); if (!state->queries[i]) goto failed; - state->queries[i]->async.fn = nbtlist_handler; + state->queries[i]->async.fn = nbtlist_handler; state->queries[i]->async.private = c; } diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index c9e2fa503b..db5aefeaeb 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -103,6 +103,7 @@ static struct composite_context *setup_next_method(struct composite_context *c) creq = method->send_fn(&state->name, c->event_ctx); } if (creq == NULL && state->methods[0]) state->methods++; + } while (!creq && state->methods[0]); if (creq) { @@ -138,9 +139,11 @@ struct composite_context *resolve_name_send(struct nbt_name *name, struct event_ c->state = COMPOSITE_STATE_IN_PROGRESS; c->private_data = state; + if (event_ctx == NULL) { c->event_ctx = event_context_init(c); if (c->event_ctx == NULL) goto failed; + } else { c->event_ctx = talloc_reference(c, event_ctx); } -- cgit