From e3ea4eeeedeafa1dba726219857be5ec980ea343 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 2 Jul 2024 16:36:26 +0200 Subject: [PATCH] feat: remove parameters from pending_queries --- include/zenoh-pico/session/session.h | 1 - src/net/primitives.c | 5 ++--- src/net/query.c | 2 +- src/session/query.c | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/zenoh-pico/session/session.h b/include/zenoh-pico/session/session.h index a7dcdcde6..de91d28fd 100644 --- a/include/zenoh-pico/session/session.h +++ b/include/zenoh-pico/session/session.h @@ -123,7 +123,6 @@ typedef struct { _z_reply_handler_t _callback; _z_drop_handler_t _dropper; void *_arg; - char *_parameters; _z_pending_reply_list_t *_pending_replies; z_query_target_t _target; z_consolidation_mode_t _consolidation; diff --git a/src/net/primitives.c b/src/net/primitives.c index 4385c7799..6dcd4c840 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -383,10 +383,9 @@ int8_t _z_query(_z_session_t *zn, _z_keyexpr_t keyexpr, const char *parameters, if (pq != NULL) { pq->_id = _z_get_query_id(zn); pq->_key = _z_get_expanded_key_from_key(zn, &keyexpr); - pq->_parameters = _z_str_clone(parameters); pq->_target = target; pq->_consolidation = consolidation; - pq->_anykey = (strstr(pq->_parameters, Z_SELECTOR_QUERY_MATCH) == NULL) ? false : true; + pq->_anykey = (strstr(parameters, Z_SELECTOR_QUERY_MATCH) == NULL) ? false : true; pq->_callback = callback; pq->_dropper = dropper; pq->_pending_replies = NULL; @@ -394,7 +393,7 @@ int8_t _z_query(_z_session_t *zn, _z_keyexpr_t keyexpr, const char *parameters, ret = _z_register_pending_query(zn, pq); // Add the pending query to the current session if (ret == _Z_RES_OK) { - _z_slice_t params = _z_slice_wrap((uint8_t *)pq->_parameters, strlen(pq->_parameters)); + _z_slice_t params = _z_slice_wrap((uint8_t *)parameters, strlen(parameters)); _z_zenoh_message_t z_msg = _z_msg_make_query(&keyexpr, ¶ms, pq->_id, pq->_consolidation, &value, timeout_ms, attachment); diff --git a/src/net/query.c b/src/net/query.c index 893f7dd40..bd08fb319 100644 --- a/src/net/query.c +++ b/src/net/query.c @@ -66,7 +66,7 @@ _z_query_t _z_query_create(const _z_value_t *value, _z_keyexpr_t *key, const _z_ q._request_id = request_id; q._zn = zn; q._parameters = (char *)z_malloc(parameters->len + 1); - memcpy(q._parameters, parameters->start, parameters->len); // TODO: Might be movable, Issue #482 + memcpy(q._parameters, parameters->start, parameters->len); q._parameters[parameters->len] = 0; q._anyke = (strstr(q._parameters, Z_SELECTOR_QUERY_MATCH) == NULL) ? false : true; q._key = _z_keyexpr_steal(key); diff --git a/src/session/query.c b/src/session/query.c index 71ceb5b64..5f885430f 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -30,7 +30,6 @@ void _z_pending_query_clear(_z_pending_query_t *pen_qry) { pen_qry->_dropper(pen_qry->_arg); } _z_keyexpr_clear(&pen_qry->_key); - _z_str_clear(pen_qry->_parameters); _z_pending_reply_list_free(&pen_qry->_pending_replies); } @@ -78,8 +77,7 @@ _z_pending_query_t *_z_get_pending_query_by_id(_z_session_t *zn, const _z_zint_t int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">>> Allocating query for (%ju:%s,%s)", (uintmax_t)pen_qry->_key._id, pen_qry->_key._suffix, - pen_qry->_parameters); + _Z_DEBUG(">>> Allocating query for (%ju:%s)", (uintmax_t)pen_qry->_key._id, pen_qry->_key._suffix); _zp_session_lock_mutex(zn);