rpcclient: Fix the timeout command
authorAndreas Schneider <asn@samba.org>
Tue, 7 Apr 2015 14:12:18 +0000 (16:12 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 9 Apr 2015 14:57:15 +0000 (16:57 +0200)
https://bugzilla.samba.org/show_bug.cgi?id=11199

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Apr  9 16:57:15 CEST 2015 on sn-devel-104

source3/rpcclient/rpcclient.c

index 47789f44835fb1851ce84199526a2e5b0a49ee37..4908518b26f98d5cd0a113e536f4b6c664ed201e 100644 (file)
@@ -487,8 +487,6 @@ static NTSTATUS cmd_seal(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 static NTSTATUS cmd_timeout(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                            int argc, const char **argv)
 {
-       struct cmd_list *tmp;
-
        if (argc > 2) {
                printf("Usage: %s timeout\n", argv[0]);
                return NT_STATUS_OK;
@@ -496,19 +494,6 @@ static NTSTATUS cmd_timeout(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 
        if (argc == 2) {
                timeout = atoi(argv[1]);
-
-               for (tmp = cmd_list; tmp; tmp = tmp->next) {
-
-                       struct cmd_set *tmp_set;
-
-                       for (tmp_set = tmp->cmd_set; tmp_set->name; tmp_set++) {
-                               if (tmp_set->rpc_pipe == NULL) {
-                                       continue;
-                               }
-
-                               rpccli_set_timeout(tmp_set->rpc_pipe, timeout);
-                       }
-               }
        }
 
        printf("timeout is %d\n", timeout);
@@ -803,6 +788,11 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                }
        }
 
+       /* Set timeout for new connections */
+       if (cmd_entry->rpc_pipe) {
+               rpccli_set_timeout(cmd_entry->rpc_pipe, timeout);
+       }
+
        /* Run command */
 
        if ( cmd_entry->returntype == RPC_RTYPE_NTSTATUS ) {
@@ -1140,7 +1130,9 @@ out_free:
 
        /* Load command lists */
        rpcclient_cli_state = cli;
-       timeout = cli_set_timeout(cli, 10000);
+
+       timeout = 10000;
+       cli_set_timeout(cli, timeout);
 
        cmd_set = rpcclient_command_list;