]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[STATS] make it possible to change a CLI connection timeout
authorWilly Tarreau <w@1wt.eu>
Tue, 26 Jan 2010 09:59:06 +0000 (10:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 Jan 2010 10:11:42 +0000 (11:11 +0100)
Sometimes it helps to be able to change an interactive CLI connection
timeout. Now we just have to enter "set timeout cli <value>" to do that.

doc/configuration.txt
src/dumpstats.c

index a1383ad77daa2bbd79a4676508a86aee11705c3b..b10714d5b2b69253d641ab1ed77ce573f103566c 100644 (file)
@@ -7553,6 +7553,11 @@ get weight <backend>/<server>
   may be specified either by their name or by their numeric ID, prefixed with a
   dash ('#').
 
+set timeout cli <delay>
+  Change the CLI interface timeout for current connection. This can be useful
+  during long debugging sessions where the user needs to constantly inspect
+  some indicators without being disconnected. The delay is passed in seconds.
+
 set weight <backend>/<server> <weight>[%]
   Change a server's weight to the value passed in argument. If the value ends
   with the '%' sign, then the new weight will be relative to the initially
index 495e28007d4bbb25fba841c088e50a7c647fd084..24b0706e2f92f3b873bbd7885099f3fdb973ea7e 100644 (file)
@@ -64,6 +64,7 @@ const char stats_sock_usage_msg[] =
        "  show sess      : report the list of current sessions\n"
        "  get weight     : report a server's current weight\n"
        "  set weight     : change a server's weight\n"
+       "  set timeout    : change a timeout setting\n"
        "";
 
 const char stats_permission_denied_msg[] =
@@ -497,7 +498,34 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
 
                        return 1;
                }
-               else { /* not "set weight" */
+               else if (strcmp(args[1], "timeout") == 0) {
+                       if (strcmp(args[2], "cli") == 0) {
+                               unsigned timeout;
+                               const char *res;
+
+                               if (!*args[3]) {
+                                       s->data_ctx.cli.msg = "Expects an integer value.\n";
+                                       si->st0 = STAT_CLI_PRINT;
+                                       return 1;
+                               }
+
+                               res = parse_time_err(args[3], &timeout, TIME_UNIT_S);
+                               if (res || timeout < 1) {
+                                       s->data_ctx.cli.msg = "Invalid timeout value.\n";
+                                       si->st0 = STAT_CLI_PRINT;
+                                       return 1;
+                               }
+
+                               s->req->rto = s->rep->wto = 1 + MS_TO_TICKS(timeout*1000);
+                               return 1;
+                       }
+                       else {
+                               s->data_ctx.cli.msg = "'set timeout' only supports 'cli'.\n";
+                               si->st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+               }
+               else { /* unknown "set" parameter */
                        return 0;
                }
        }