diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-28 02:37:14 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2005-08-28 02:37:14 +0000 |
commit | b7b1bb18ec1bfc3bd88ce1c14a1d24876158673f (patch) | |
tree | c64d18f47216bf232c11d1fa52bf7130c009db51 /source/lib/socket/connect.c | |
parent | 265e963ca6f4825fbbfd2fc02a6acbc23a5ead7f (diff) | |
download | samba-b7b1bb18ec1bfc3bd88ce1c14a1d24876158673f.tar.gz samba-b7b1bb18ec1bfc3bd88ce1c14a1d24876158673f.tar.xz samba-b7b1bb18ec1bfc3bd88ce1c14a1d24876158673f.zip |
r9702: r9680@blu: tridge | 2005-08-27 18:45:08 +1000
- fixed ncacn_ip_tcp to use the generic async name resolution methods,
so NBT names now work (as requested several times by abartlet!)
- changed resolve_name() to take an event_context, so it doesn't cause
the whole process to block
- cleaned up the talloc_find_parent_bytype() calls to go via a cleaner
event_context_find() call
Diffstat (limited to 'source/lib/socket/connect.c')
-rw-r--r-- | source/lib/socket/connect.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/lib/socket/connect.c b/source/lib/socket/connect.c index abe474720cb..567c8f41d28 100644 --- a/source/lib/socket/connect.c +++ b/source/lib/socket/connect.c @@ -24,6 +24,29 @@ #include "includes.h" #include "lib/socket/socket.h" #include "lib/events/events.h" +#include "librpc/gen_ndr/nbt.h" + + +/* + async name resolution handler for socket_connect_ev, returnes either + an IP address or 'localhost' (which is specially recognised) +*/ +static NTSTATUS connect_resolve(TALLOC_CTX *mem_ctx, const char *address, + struct event_context *ev, const char **ret_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; + + return resolve_name(&name, mem_ctx, ret_address, ev); +} /* @@ -52,6 +75,16 @@ NTSTATUS socket_connect_ev(struct socket_context *sock, TALLOC_CTX *tmp_ctx = talloc_new(sock); NTSTATUS status; + /* + we resolve separately to ensure that the name resolutions happens + asynchronously + */ + status = connect_resolve(tmp_ctx, server_address, ev, &server_address); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return status; + } + set_blocking(socket_get_fd(sock), False); status = socket_connect(sock, my_address, my_port, |