lib: bt_query_executor_query(): check interruption state before querying
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 14:25:05 +0000 (10:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 16:00:31 +0000 (12:00 -0400)
This patch makes bt_query_executor_query() check its interruption state
(with bt_query_executor_is_interrupted()) before it calls the user
method. This is just a convenience so that the user does not need to
check bt_query_executor_is_interrupted() for every
bt_query_executor_query() call.

The comment `query-executor.c` explains why the function returns
`BT_QUERY_EXECUTOR_QUERY_STATUS_AGAIN` in that case.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3bfceed538601d83c1ab627f5241c59f9f2e7c49
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1757
Tested-by: jenkins <jenkins@lttng.org>
src/lib/graph/query-executor.c

index 1addeeb302311ddb7ce71c2dc5e114e5d4771ec6..03d420ece1fb55f5aca37f96400fa8bb134bb2c1 100644 (file)
@@ -117,6 +117,28 @@ enum bt_query_executor_query_status bt_query_executor_query(
        BT_ASSERT_PRE_NON_NULL(object, "Object");
        BT_ASSERT_PRE_NON_NULL(user_result, "Result (output)");
 
+       /*
+        * Initial check: is the query executor already interrupted? If
+        * so, return `BT_FUNC_STATUS_AGAIN`. Returning this status is
+        * harmless: it's not `BT_FUNC_STATUS_OK` (there's no result),
+        * and it's not `BT_FUNC_STATUS_ERROR` either (there's no
+        * legitimate error). Since any query operation could return
+        * `BT_FUNC_STATUS_AGAIN` when interrupted or instead of
+        * blocking, the caller is responsible for checking the
+        * interruption state of the query executor when getting this
+        * status.
+        */
+       if (bt_query_executor_is_interrupted(query_exec)) {
+               BT_LIB_LOGD("Query executor is interrupted: "
+                       "not performing the query operation: "
+                       "query-exec-addr=%p, %![cc-]+C, object=\"%s\", "
+                       "%![params-]+v, log-level=%s",
+                       query_exec, comp_cls, object, params,
+                       bt_common_logging_level_string(log_level));
+               status = BT_FUNC_STATUS_AGAIN;
+               goto end;
+       }
+
        if (!params) {
                params = bt_value_null;
        }
This page took 0.02744 seconds and 4 git commands to generate.