From: Philippe Proulx Date: Wed, 24 Jul 2019 14:25:05 +0000 (-0400) Subject: lib: bt_query_executor_query(): check interruption state before querying X-Git-Tag: v2.0.0-rc1~420 X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=c7f8c4e43a72dd669e76c132bc7bd145679072af;p=babeltrace.git lib: bt_query_executor_query(): check interruption state before querying 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 Change-Id: I3bfceed538601d83c1ab627f5241c59f9f2e7c49 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1757 Tested-by: jenkins --- diff --git a/src/lib/graph/query-executor.c b/src/lib/graph/query-executor.c index 1addeeb3..03d420ec 100644 --- a/src/lib/graph/query-executor.c +++ b/src/lib/graph/query-executor.c @@ -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; }