lttng enable-channel: --blocking-timeout opt.: use `inf` instead of -1
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jul 2017 19:48:32 +0000 (15:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 1 Aug 2017 21:01:20 +0000 (17:01 -0400)
It might be -1 for the API, but for a command-line interface used by
humans, `inf` is more meaningful than -1.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/enable_channels.c
tests/regression/ust/blocking/test_blocking

index 19490477e4a65f4e1d8cee8b61d53787483cebb3..48c21109527cb6c28c9c242f817e5d4865fb4dcd 100644 (file)
@@ -556,42 +556,50 @@ int cmd_enable_channels(int argc, const char **argv)
 
                        errno = 0;
                        opt_arg = poptGetOptArg(pc);
+
+                       if (strcmp(opt_arg, "inf") == 0) {
+                               opt_blocking_timeout.value = (int64_t) -1;
+                               opt_blocking_timeout.set = true;
+                               DBG("Channel blocking timeout set to infinity");
+                               break;
+                       }
+
                        v = strtoll(opt_arg, NULL, 0);
                        if (errno != 0 || (!isdigit(opt_arg[0]) && opt_arg[0] != '-')
-                                       || v < -1) {
+                                       || v < 0) {
                                ERR("Wrong value in --blocking-timeout parameter: %s", opt_arg);
                                ret = CMD_ERROR;
                                goto end;
                        }
-                       if (v >= 0) {
-                               /*
-                                * While LTTng-UST and LTTng-tools will accept
-                                * a blocking timeout expressed in µs, the
-                                * current tracer implementation relies on
-                                * poll() which takes an "int timeout" parameter
-                                * expressed in msec.
-                                *
-                                * Since the error reporting from the tracer
-                                * is not precise, we perform this check here
-                                * to provide a helpful error message in case of
-                                * overflow.
-                                *
-                                * The setter (liblttng-ctl) also performs an
-                                * equivalent check.
-                                */
-                               v_msec = v / 1000;
-                               if (v_msec != (int32_t) v_msec) {
-                                       ERR("32-bit milliseconds overflow in --blocking-timeout parameter: %s", opt_arg);
-                                       ret = CMD_ERROR;
-                                       goto end;
-                               }
-                       } else if (v != -1) {
-                               ERR("Invalid negative value passed as --blocking-timeout parameter; -1 (block forever) is the only valid negative value");
+
+                       /*
+                        * While LTTng-UST and LTTng-tools will accept a
+                        * blocking timeout expressed in µs, the current
+                        * tracer implementation relies on poll() which
+                        * takes an "int timeout" parameter expressed in
+                        * msec.
+                        *
+                        * Since the error reporting from the tracer is
+                        * not precise, we perform this check here to
+                        * provide a helpful error message in case of
+                        * overflow.
+                        *
+                        * The setter (liblttng-ctl) also performs an
+                        * equivalent check.
+                        */
+                       v_msec = v / 1000;
+                       if (v_msec != (int32_t) v_msec) {
+                               ERR("32-bit milliseconds overflow in --blocking-timeout parameter: %s", opt_arg);
+                               ret = CMD_ERROR;
+                               goto end;
                        }
+
                        opt_blocking_timeout.value = (int64_t) v;
                        opt_blocking_timeout.set = true;
-                       DBG("Channel blocking timeout set to %" PRId64 " (µs)",
-                                       opt_blocking_timeout.value);
+                       DBG("Channel blocking timeout set to %" PRId64 " µs%s",
+                                       opt_blocking_timeout.value,
+                                       opt_blocking_timeout.value == 0 ?
+                                               " (non-blocking)" : "");
                        break;
                }
                case OPT_USERSPACE:
index c5c95903b0190f06efe639691129fc8d1d923496..b1c3f2d09d86a9449db2f5a011a61c1f781dd76d 100755 (executable)
@@ -60,12 +60,12 @@ function test_ust_implicit_no_blocking()
 function test_ust_implicit_no_blocking_with_channel_blocking()
 {
        NUM_EVENT=5000000
-       diag "UST implicit non-blocking mode (default) with blocking-timeout=-1 channel: will hang if fails"
+       diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
 
        start_lttng_sessiond
        # session in no-output mode
        create_lttng_session_no_output $SESSION_NAME
-       enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1"
+       enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
        enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
        start_lttng_tracing_ok $SESSION_NAME
        run_app
@@ -125,7 +125,7 @@ function test_ust_blocking_no_discard()
        start_lttng_sessiond
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
        # infinite blocking timeout
-       enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1"
+       enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
        enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
        start_lttng_tracing_ok $SESSION_NAME
        LTTNG_UST_ALLOW_BLOCKING=1 run_app
This page took 0.0272559999999999 seconds and 4 git commands to generate.