cli: remove the global volatile `interrupted` variable
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 14:25:17 +0000 (10:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 16:00:31 +0000 (12:00 -0400)
We can use the global interrupter's state instead, and we don't need to
check the interruption status before calling bt_query_executor_query()
and bt_graph_run() as both functions check their interruption state
initially.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3818843c44b016cf2b872d879b461eae52730e6b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1758
Tested-by: jenkins <jenkins@lttng.org>
src/cli/babeltrace2.c

index 9699b0c3b5e46fba695fbbf6d4614df0f413f559..a0c6df110e09af00a326906cd404877bdae10b34 100644 (file)
@@ -57,7 +57,6 @@ static const char* log_level_env_var_names[] = {
 
 /* Application's interrupter (owned by this) */
 static bt_interrupter *the_interrupter;
-static volatile bool interrupted = false;
 
 #ifdef __MINGW32__
 
@@ -69,7 +68,6 @@ BOOL WINAPI signal_handler(DWORD signal) {
                bt_interrupter_set(the_interrupter);
        }
 
-       interrupted = true;
        return TRUE;
 }
 
@@ -93,8 +91,6 @@ void signal_handler(int signum)
        if (the_interrupter) {
                bt_interrupter_set(the_interrupter);
        }
-
-       interrupted = true;
 }
 
 static
@@ -135,16 +131,6 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls,
 
        bt_query_executor_add_interrupter(query_exec, the_interrupter);
 
-       if (interrupted) {
-               BT_CLI_LOGW_APPEND_CAUSE(
-                       "Interrupted by user before executing the query: "
-                       "comp-cls-addr=%p, comp-cls-name=\"%s\", "
-                       "query-obj=\"%s\"", comp_cls,
-                       bt_component_class_get_name(comp_cls), obj);
-               *fail_reason = "interrupted by user";
-               goto error;
-       }
-
        while (true) {
                query_status = bt_query_executor_query(
                        query_exec, comp_cls, obj, params,
@@ -2311,7 +2297,7 @@ int cmd_run(struct bt_config *cfg)
                goto error;
        }
 
-       if (interrupted) {
+       if (bt_interrupter_is_set(the_interrupter)) {
                BT_CLI_LOGW_APPEND_CAUSE(
                        "Interrupted by user before creating components.");
                goto error;
@@ -2325,7 +2311,7 @@ int cmd_run(struct bt_config *cfg)
                goto error;
        }
 
-       if (interrupted) {
+       if (bt_interrupter_is_set(the_interrupter)) {
                BT_CLI_LOGW_APPEND_CAUSE(
                        "Interrupted by user before connecting components.");
                goto error;
@@ -2340,12 +2326,6 @@ int cmd_run(struct bt_config *cfg)
                goto error;
        }
 
-       if (interrupted) {
-               BT_CLI_LOGW_APPEND_CAUSE(
-                       "Interrupted by user before running the graph.");
-               goto error;
-       }
-
        BT_LOGI_STR("Running the graph.");
 
        /* Run the graph */
This page took 0.026581 seconds and 4 git commands to generate.