diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h index 964fc876d..c0d258b1b 100644 --- a/include/zenoh-pico/config.h +++ b/include/zenoh-pico/config.h @@ -119,12 +119,19 @@ #endif /** - * Enable queries and queryables + * Enable queryables */ #ifndef Z_FEATURE_QUERYABLES #define Z_FEATURE_QUERYABLES 1 #endif +/** + * Enable queries +*/ +#ifndef Z_FEATURE_QUERIES +#define Z_FEATURE_QUERIES 1 +#endif + /** * Enable TCP links. */ diff --git a/include/zenoh-pico/net/query.h b/include/zenoh-pico/net/query.h index cb59f6dd5..9b33dfb67 100644 --- a/include/zenoh-pico/net/query.h +++ b/include/zenoh-pico/net/query.h @@ -39,7 +39,9 @@ typedef struct { void *_zn; // FIXME: _z_session_t *zn; } _z_queryable_t; +#if Z_FEATURE_QUERYABLES == 1 void _z_queryable_clear(_z_queryable_t *qbl); void _z_queryable_free(_z_queryable_t **qbl); +#endif #endif /* ZENOH_PICO_QUERY_NETAPI_H */ diff --git a/include/zenoh-pico/net/session.h b/include/zenoh-pico/net/session.h index d0d3654f7..484d3cfad 100644 --- a/include/zenoh-pico/net/session.h +++ b/include/zenoh-pico/net/session.h @@ -53,9 +53,11 @@ typedef struct { _z_subscription_sptr_list_t *_local_subscriptions; _z_subscription_sptr_list_t *_remote_subscriptions; -#if Z_FEATURE_QUERYABLES == 1 // Session queryables +#if Z_FEATURE_QUERYABLES == 1 _z_questionable_sptr_list_t *_local_questionable; +#endif +#if Z_FEATURE_QUERIES == 1 _z_pending_query_list_t *_pending_queries; #endif } _z_session_t; diff --git a/include/zenoh-pico/session/query.h b/include/zenoh-pico/session/query.h index 089eb6edf..e62188bfb 100644 --- a/include/zenoh-pico/session/query.h +++ b/include/zenoh-pico/session/query.h @@ -18,7 +18,7 @@ #include "zenoh-pico/net/session.h" #include "zenoh-pico/protocol/core.h" -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 /*------------------ Query ------------------*/ _z_zint_t _z_get_query_id(_z_session_t *zn); diff --git a/src/api/api.c b/src/api/api.c index c18aa27a8..d961cde0b 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -429,7 +429,7 @@ OWNED_FUNCTIONS_PTR_INTERNAL(z_keyexpr_t, z_owned_keyexpr_t, keyexpr, _z_keyexpr OWNED_FUNCTIONS_PTR_INTERNAL(z_hello_t, z_owned_hello_t, hello, _z_hello_free, _z_owner_noop_copy) OWNED_FUNCTIONS_PTR_INTERNAL(z_str_array_t, z_owned_str_array_t, str_array, _z_str_array_free, _z_owner_noop_copy) -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 OWNED_FUNCTIONS_PTR_INTERNAL(z_reply_t, z_owned_reply_t, reply, _z_reply_free, _z_owner_noop_copy) #endif @@ -657,7 +657,7 @@ typedef struct __z_reply_handler_wrapper_t { } __z_reply_handler_wrapper_t; void __z_reply_handler(_z_reply_t *reply, __z_reply_handler_wrapper_t *wrapped_ctx) { -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_owned_reply_t oreply = {._value = reply}; wrapped_ctx->user_call(&oreply, wrapped_ctx->ctx); @@ -667,7 +667,7 @@ void __z_reply_handler(_z_reply_t *reply, __z_reply_handler_wrapper_t *wrapped_c int8_t z_get(z_session_t zs, z_keyexpr_t keyexpr, const char *parameters, z_owned_closure_reply_t *callback, const z_get_options_t *options) { -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 int8_t ret = _Z_RES_OK; void *ctx = callback->context; diff --git a/src/net/primitives.c b/src/net/primitives.c index aa961b10e..efd54dc82 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -303,7 +303,9 @@ int8_t _z_send_reply(const z_query_t *query, _z_keyexpr_t keyexpr, const _z_valu return ret; } +#endif +#if Z_FEATURE_QUERIES == 1 /*------------------ Query ------------------*/ int8_t _z_query(_z_session_t *zn, _z_keyexpr_t keyexpr, const char *parameters, const z_query_target_t target, const z_consolidation_mode_t consolidation, _z_value_t value, _z_reply_handler_t callback, diff --git a/src/session/query.c b/src/session/query.c index 67a64d5fd..1eba46ef8 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -22,7 +22,7 @@ #include "zenoh-pico/session/resource.h" #include "zenoh-pico/utils/logging.h" -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 _z_reply_t *_z_reply_alloc_and_move(_z_reply_t *_reply) { _z_reply_t *reply = (_z_reply_t *)z_malloc(sizeof(_z_reply_t)); if (reply != NULL) { diff --git a/src/session/rx.c b/src/session/rx.c index 164881863..903e8eed6 100644 --- a/src/session/rx.c +++ b/src/session/rx.c @@ -96,7 +96,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint _z_msg_query_t *query = &req._body._query; ret = _z_trigger_queryables(zn, query, req._key, req._rid); #else - _Z_DEBUG("_Z_REQUEST_QUERY dropped, queries not supported\n"); + _Z_DEBUG("_Z_REQUEST_QUERY dropped, queryables not supported\n"); #endif } break; case _Z_REQUEST_PUT: { @@ -131,7 +131,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint _z_n_msg_response_t response = msg->_body._response; switch (response._tag) { case _Z_RESPONSE_BODY_REPLY: { -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 _z_msg_reply_t reply = response._body._reply; ret = _z_trigger_query_reply_partial(zn, response._request_id, response._key, reply._value.payload, reply._value.encoding, Z_SAMPLE_KIND_PUT, reply._timestamp); @@ -162,7 +162,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint } } break; case _Z_N_RESPONSE_FINAL: { -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 _Z_DEBUG("Handling _Z_N_RESPONSE_FINAL\n"); _z_zint_t id = msg->_body._response_final._request_id; _z_trigger_query_reply_final(zn, id); diff --git a/src/session/utils.c b/src/session/utils.c index b0b2bd879..717f306d9 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -65,6 +65,8 @@ int8_t _z_session_init(_z_session_t *zn, _z_id_t *zid) { zn->_remote_subscriptions = NULL; #if Z_FEATURE_QUERYABLES == 1 zn->_local_questionable = NULL; +#endif +#if Z_FEATURE_QUERIES == 1 zn->_pending_queries = NULL; #endif @@ -105,6 +107,8 @@ void _z_session_clear(_z_session_t *zn) { #if Z_FEATURE_QUERYABLES == 1 _z_flush_questionables(zn); +#endif +#if Z_FEATURE_QUERIES == 1 _z_flush_pending_queries(zn); #endif diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 0b9d6da08..15adeba88 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -40,7 +40,7 @@ int main(void) { z_owned_closure_zid_t closure_zid_null_1 = z_closure_zid_null(); z_owned_str_t str_null_1 = z_str_null(); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_owned_reply_t reply_null_1 = z_reply_null(); #endif @@ -58,7 +58,7 @@ int main(void) { assert(!z_check(hello_null_1)); assert(!z_check(str_null_1)); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 assert(!z_check(reply_null_1)); #endif @@ -81,7 +81,7 @@ int main(void) { z_owned_closure_zid_t closure_zid_null_2; z_owned_str_t str_null_2; -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_owned_reply_t reply_null_2; #endif @@ -101,7 +101,7 @@ int main(void) { z_null(&closure_zid_null_2); z_null(&str_null_2); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_null(&reply_null_2); #endif @@ -119,7 +119,7 @@ int main(void) { assert(!z_check(hello_null_2)); assert(!z_check(str_null_2)); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 assert(!z_check(reply_null_2)); #endif @@ -143,7 +143,7 @@ int main(void) { z_drop(z_move(closure_zid_null_1)); z_drop(z_move(str_null_1)); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_drop(z_move(reply_null_1)); #endif @@ -163,7 +163,7 @@ int main(void) { z_drop(z_move(closure_zid_null_2)); z_drop(z_move(str_null_2)); -#if Z_FEATURE_QUERYABLES == 1 +#if Z_FEATURE_QUERIES == 1 z_drop(z_move(reply_null_2)); #endif }