]>
Commit | Line | Data |
---|---|---|
1d13e637 AF |
1 | commit e8f6a7df1b5ae7f7275ac59b8c21b82de1922c3b |
2 | Author: Jeremy Allison <jra@samba.org> | |
3 | AuthorDate: Fri Aug 16 13:49:39 2013 -0700 | |
4 | Commit: Andreas Schneider <asn@samba.org> | |
5 | CommitDate: Wed Feb 5 11:50:28 2014 +0100 | |
6 | ||
7 | Add new "timeout" command and -t option to smbclient to set the per-operation timeout. | |
8 | ||
9 | This is needed as once SMB3 encryption is selected the server | |
10 | response time can be very slow when requesting large numbers | |
11 | (256) of large encrypted packets (1MB) from a Windows 2012 | |
12 | virtual machine. This allows clients to tune their allowable | |
13 | wait time. | |
14 | ||
15 | Signed-off-by: Jeremy Allison <jra@samba.org> | |
16 | Reviewed-by: Michael Adam <obnox@samba.org> | |
17 | (cherry picked from commit d9c88a56dc451be09e8c9fc9aa8857e312fcb444) | |
18 | --- | |
19 | source3/client/client.c | 44 ++++++++++++++++++++++++++++++++++++++++---- | |
20 | 1 file changed, 40 insertions(+), 4 deletions(-) | |
21 | ||
22 | diff --git a/source3/client/client.c b/source3/client/client.c | |
23 | index f6e42f6..aa16b14 100644 | |
24 | --- a/source3/client/client.c | |
25 | +++ b/source3/client/client.c | |
26 | @@ -54,7 +54,12 @@ static bool grepable = false; | |
27 | static char *cmdstr = NULL; | |
28 | const char *cmd_ptr = NULL; | |
29 | ||
30 | +/* 30 second timeout on most commands */ | |
31 | +#define CLIENT_TIMEOUT (30*1000) | |
32 | +#define SHORT_TIMEOUT (5*1000) | |
33 | + | |
34 | static int io_bufsize = 524288; | |
35 | +static int io_timeout = (CLIENT_TIMEOUT/1000); /* Per operation timeout (in seconds). */ | |
36 | ||
37 | static int name_type = 0x20; | |
38 | static int max_protocol = PROTOCOL_NT1; | |
39 | @@ -64,10 +69,6 @@ static int cmd_help(void); | |
40 | ||
41 | #define CREATE_ACCESS_READ READ_CONTROL_ACCESS | |
42 | ||
43 | -/* 30 second timeout on most commands */ | |
44 | -#define CLIENT_TIMEOUT (30*1000) | |
45 | -#define SHORT_TIMEOUT (5*1000) | |
46 | - | |
47 | /* value for unused fid field in trans2 secondary request */ | |
48 | #define FID_UNUSED (0xFFFF) | |
49 | ||
50 | @@ -4264,6 +4265,31 @@ int cmd_iosize(void) | |
51 | } | |
52 | ||
53 | /**************************************************************************** | |
54 | + timeout command | |
55 | +***************************************************************************/ | |
56 | + | |
57 | +static int cmd_timeout(void) | |
58 | +{ | |
59 | + TALLOC_CTX *ctx = talloc_tos(); | |
60 | + char *buf; | |
61 | + | |
62 | + if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { | |
63 | + unsigned int old_timeout = cli_set_timeout(cli, 0); | |
64 | + cli_set_timeout(cli, old_timeout); | |
65 | + d_printf("timeout <n> (per-operation timeout " | |
66 | + "in seconds - currently %u).\n", | |
67 | + old_timeout/1000); | |
68 | + return 1; | |
69 | + } | |
70 | + | |
71 | + io_timeout = strtol(buf,NULL,0); | |
72 | + cli_set_timeout(cli, io_timeout*1000); | |
73 | + d_printf("io_timeout per operation is now %d\n", io_timeout); | |
74 | + return 0; | |
75 | +} | |
76 | + | |
77 | + | |
78 | +/**************************************************************************** | |
79 | history | |
80 | ****************************************************************************/ | |
81 | static int cmd_history(void) | |
82 | @@ -4369,6 +4395,7 @@ static struct { | |
83 | {"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}}, | |
84 | {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}}, | |
85 | {"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}}, | |
86 | + {"timeout",cmd_timeout,"timeout <number> - set the per-operation timeout in seconds (default 20)",{COMPL_NONE,COMPL_NONE}}, | |
87 | {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}}, | |
88 | {"unlock",cmd_unlock,"unlock <fnum> <hex-start> <hex-len> : remove a POSIX lock",{COMPL_REMOTE,COMPL_REMOTE}}, | |
89 | {"volume",cmd_volume,"print the volume name",{COMPL_NONE,COMPL_NONE}}, | |
90 | @@ -4465,6 +4492,7 @@ static int process_command_string(const char *cmd_in) | |
91 | if (!cli) { | |
92 | return 1; | |
93 | } | |
94 | + cli_set_timeout(cli, io_timeout*1000); | |
95 | } | |
96 | ||
97 | while (cmd[0] != '\0') { | |
98 | @@ -4942,6 +4970,8 @@ static int process(const char *base_directory) | |
99 | return 1; | |
100 | } | |
101 | ||
102 | + cli_set_timeout(cli, io_timeout*1000); | |
103 | + | |
104 | if (base_directory && *base_directory) { | |
105 | rc = do_cd(base_directory); | |
106 | if (rc) { | |
107 | @@ -4972,6 +5002,7 @@ static int do_host_query(const char *query_host) | |
108 | if (!cli) | |
109 | return 1; | |
110 | ||
111 | + cli_set_timeout(cli, io_timeout*1000); | |
112 | browse_host(true); | |
113 | ||
114 | /* Ensure that the host can do IPv4 */ | |
115 | @@ -5003,6 +5034,7 @@ static int do_host_query(const char *query_host) | |
116 | return 1; | |
117 | } | |
118 | ||
119 | + cli_set_timeout(cli, io_timeout*1000); | |
120 | list_servers(lp_workgroup()); | |
121 | ||
122 | cli_shutdown(cli); | |
123 | @@ -5026,6 +5058,7 @@ static int do_tar_op(const char *base_directory) | |
124 | max_protocol, port, name_type); | |
125 | if (!cli) | |
126 | return 1; | |
127 | + cli_set_timeout(cli, io_timeout*1000); | |
128 | } | |
129 | ||
130 | recurse=true; | |
131 | @@ -5091,6 +5124,8 @@ static int do_message_op(struct user_auth_info *a_info) | |
132 | return 1; | |
133 | } | |
134 | ||
135 | + cli_set_timeout(cli, io_timeout*1000); | |
136 | + | |
137 | send_message(get_cmdline_auth_info_username(a_info)); | |
138 | cli_shutdown(cli); | |
139 | ||
140 | @@ -5127,6 +5162,7 @@ static int do_message_op(struct user_auth_info *a_info) | |
141 | { "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" }, | |
142 | { "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" }, | |
143 | { "send-buffer", 'b', POPT_ARG_INT, &io_bufsize, 'b', "Changes the transmit/send buffer", "BYTES" }, | |
144 | + { "timeout", 't', POPT_ARG_INT, &io_timeout, 'b', "Changes the per-operation timeout", "SECONDS" }, | |
145 | { "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" }, | |
146 | { "grepable", 'g', POPT_ARG_NONE, NULL, 'g', "Produce grepable output" }, | |
147 | { "browse", 'B', POPT_ARG_NONE, NULL, 'B', "Browse SMB servers using DNS" }, |