diff options
author | Simo Sorce <idra@samba.org> | 2008-04-21 17:58:23 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-04-21 18:12:33 -0400 |
commit | 4e83011f72ba3df387512755a17760b42a7bf2f2 (patch) | |
tree | 8870bc1bf9181d3ed732db64324307fe533a07d6 /source4/client/client.c | |
parent | 8a3e3391fb82c2ee8ef67dbded753d6fad564827 (diff) | |
download | samba-4e83011f72ba3df387512755a17760b42a7bf2f2.tar.gz samba-4e83011f72ba3df387512755a17760b42a7bf2f2.tar.bz2 samba-4e83011f72ba3df387512755a17760b42a7bf2f2.zip |
Remove more event_context_init() uses from function calls within deep down the code.
Make sure we pass around the event_context where we need it instead.
All test but a few python ones fail. Jelmer promised to fix them.
(This used to be commit 3045d391626fba169aa26be52174883e18d323e9)
Diffstat (limited to 'source4/client/client.c')
-rw-r--r-- | source4/client/client.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/source4/client/client.c b/source4/client/client.c index ef88913c4d..79cc1b5382 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -2546,7 +2546,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1) /**************************************************************************** try and browse available shares on a host ****************************************************************************/ -static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host) +static bool browse_host(struct loadparm_context *lp_ctx, + struct event_context *ev_ctx, + const char *query_host) { struct dcerpc_pipe *p; char *binding; @@ -2560,7 +2562,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host) status = dcerpc_pipe_connect(mem_ctx, &p, binding, &ndr_table_srvsvc, - cmdline_credentials, NULL, + cmdline_credentials, ev_ctx, lp_ctx); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to connect to %s - %s\n", @@ -3022,6 +3024,7 @@ static int process_stdin(struct smbclient_context *ctx) return a connection to a server *******************************************************/ static bool do_connect(struct smbclient_context *ctx, + struct event_context *ev_ctx, struct resolve_context *resolve_ctx, const char *specified_server, const char **ports, const char *specified_share, @@ -3045,8 +3048,7 @@ static bool do_connect(struct smbclient_context *ctx, status = smbcli_full_connection(ctx, &ctx->cli, server, ports, share, NULL, cred, resolve_ctx, - event_context_init(NULL), - options); + ev_ctx, options); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to \\\\%s\\%s failed - %s\n", server, share, nt_errstr(status)); @@ -3060,9 +3062,12 @@ static bool do_connect(struct smbclient_context *ctx, /**************************************************************************** handle a -L query ****************************************************************************/ -static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup) +static int do_host_query(struct loadparm_context *lp_ctx, + struct event_context *ev_ctx, + const char *query_host, + const char *workgroup) { - browse_host(lp_ctx, query_host); + browse_host(lp_ctx, ev_ctx, query_host); list_servers(workgroup); return(0); } @@ -3071,7 +3076,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host /**************************************************************************** handle a message operation ****************************************************************************/ -static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options) +static int do_message_op(const char *netbios_name, const char *desthost, + const char **destports, const char *destip, + int name_type, + struct event_context *ev_ctx, + struct resolve_context *resolve_ctx, + struct smbcli_options *options) { struct nbt_name called, calling; const char *server_name; @@ -3083,7 +3093,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c server_name = destip ? destip : desthost; - if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) { + if (!(cli = smbcli_state_init(NULL)) || + !smbcli_socket_connect(cli, server_name, destports, + ev_ctx, resolve_ctx, options)) { d_printf("Connection to %s failed\n", server_name); return 1; } @@ -3124,6 +3136,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c int rc = 0; int name_type = 0x20; TALLOC_CTX *mem_ctx; + struct event_context *ev_ctx; struct smbclient_context *ctx; const char *cmdstr = NULL; struct smbcli_options smb_options; @@ -3221,6 +3234,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c lp_smbcli_options(cmdline_lp_ctx, &smb_options); + ev_ctx = event_context_init(talloc_autofree_context()); + DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) ); if (query_host && (p=strchr_m(query_host,'#'))) { @@ -3230,14 +3245,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } if (query_host) { - return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx)); + rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host, + lp_workgroup(cmdline_lp_ctx)); + return rc; } if (message) { - return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options); + rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, + lp_smb_ports(cmdline_lp_ctx), dest_ip, + name_type, ev_ctx, + lp_resolve_context(cmdline_lp_ctx), + &smb_options); + return rc; } - if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options)) + if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx), + desthost, lp_smb_ports(cmdline_lp_ctx), service, + cmdline_credentials, &smb_options)) return 1; if (base_directory) |