Skip to content

Commit

Permalink
fix: queryables issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Dec 3, 2024
1 parent e530209 commit 2c79ab7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/net/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void _z_query_clear_inner(_z_query_t *q) {
z_result_t _z_query_send_reply_final(_z_query_t *q) {
// Try to upgrade session weak to rc
_z_session_rc_t sess_rc = _z_session_weak_upgrade_if_open(&q->_zn);
if (!_Z_RC_IS_NULL(&sess_rc)) {
if (_Z_RC_IS_NULL(&sess_rc)) {
return _Z_ERR_TRANSPORT_TX_FAILED;
}
_z_zenoh_message_t z_msg = _z_n_msg_make_response_final(q->_request_id);
Expand Down
11 changes: 10 additions & 1 deletion src/session/queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static z_result_t _z_session_queryable_get_infos(_z_session_t *zn, const _z_keye
return _Z_RES_OK;
}

static z_result_t _z_trigger_queryables_inner(_z_session_rc_t *zsrc, _z_msg_query_t *msgq, const _z_keyexpr_t *q_key,
static z_result_t _z_trigger_queryables_inner(_z_session_rc_t *zsrc, _z_msg_query_t *msgq, _z_keyexpr_t *q_key,
uint32_t qid) {
_z_session_t *zn = _Z_RC_IN_VAL(zsrc);
_z_keyexpr_t key;
Expand All @@ -227,6 +227,15 @@ static z_result_t _z_trigger_queryables_inner(_z_session_rc_t *zsrc, _z_msg_quer
_z_query_t q =
_z_query_alias(&msgq->_ext_value, &key, &msgq->_parameters, zsrc, qid, &msgq->_ext_attachment, anyke);
_z_query_rc_t query = _z_query_rc_new_from_val(&q);
if (_Z_RC_IS_NULL(&query)) {
return _Z_ERR_SYSTEM_OUT_OF_MEMORY;
}
// Clear values to avoid double free
*q_key = _z_keyexpr_null();
msgq->_ext_value.encoding = _z_encoding_null();
msgq->_ext_value.payload = _z_bytes_null();
msgq->_ext_attachment = _z_bytes_null();
msgq->_parameters = _z_slice_null();
// Parse session_queryable svec
for (size_t i = 0; i < qle_nb; i++) {
_z_queryable_infos_t *qle_info = _z_queryable_infos_svec_get(&qles, i);
Expand Down

0 comments on commit 2c79ab7

Please sign in to comment.