summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2005-09-29 22:37:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:13 -0500
commit9bc38ce65f1907230618b3edccafb1d33f753fe0 (patch)
treeb6c59a07165c0d9e52010f7d615b780d76a77ec4
parent65271095d0aaf3b4fb10ae5639b89ae31ba80774 (diff)
downloadsamba-9bc38ce65f1907230618b3edccafb1d33f753fe0.tar.gz
samba-9bc38ce65f1907230618b3edccafb1d33f753fe0.tar.bz2
samba-9bc38ce65f1907230618b3edccafb1d33f753fe0.zip
r10636: Formatting for better readability.
rafal (This used to be commit ef29863d999089c47140bd37731c60659a200421)
-rw-r--r--source4/libcli/resolve/nbtlist.c18
-rw-r--r--source4/libcli/resolve/resolve.c3
2 files changed, 15 insertions, 6 deletions
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;i<state->num_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;i<q->out.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;i<state->num_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);
}