Skip to content

Commit

Permalink
fix: missing send reply final
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Nov 16, 2024
1 parent e2c7976 commit 4a10390
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/zenoh-pico/net/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static inline bool _z_query_check(const _z_query_t *query) {
return _z_keyexpr_check(&query->_key) || _z_value_check(&query->_value) || _z_bytes_check(&query->_attachment) ||
_z_string_check(&query->_parameters);
}
z_result_t _z_query_send_reply_final(_z_query_t *q);
void _z_query_clear(_z_query_t *q);
z_result_t _z_query_copy(_z_query_t *dst, const _z_query_t *src);
void _z_query_free(_z_query_t **query);
Expand Down
23 changes: 14 additions & 9 deletions src/net/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@
#include "zenoh-pico/transport/common/tx.h"
#include "zenoh-pico/utils/logging.h"

void _z_query_clear_inner(_z_query_t *q) {
static void _z_query_clear_inner(_z_query_t *q) {
_z_keyexpr_clear(&q->_key);
_z_value_clear(&q->_value);
_z_bytes_drop(&q->_attachment);
_z_string_clear(&q->_parameters);
_z_session_rc_drop(&q->_zn);
}

z_result_t _z_query_send_reply_final(_z_query_t *q) {
if (_Z_RC_IS_NULL(&q->_zn)) {
return _Z_ERR_TRANSPORT_TX_FAILED;
}
_z_zenoh_message_t z_msg = _z_n_msg_make_response_final(q->_request_id);
z_result_t ret = _z_send_n_msg(_Z_RC_IN_VAL(&q->_zn), &z_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK);
_z_msg_clear(&z_msg);
return ret;
}

void _z_query_clear(_z_query_t *q) {
if (!_Z_RC_IS_NULL(&q->_zn)) {
// Send REPLY_FINAL message
_z_zenoh_message_t z_msg = _z_n_msg_make_response_final(q->_request_id);
if (_z_send_n_msg(_Z_RC_IN_VAL(&q->_zn), &z_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) !=
_Z_RES_OK) {
_Z_ERROR("Query send REPLY_FINAL transport failure !");
}
_z_msg_clear(&z_msg);
// Send REPLY_FINAL message
if (_z_query_send_reply_final(q) != _Z_RES_OK) {
_Z_ERROR("Query send REPLY_FINAL transport failure !");
}
// Clean up memory
_z_query_clear_inner(q);
Expand Down
2 changes: 2 additions & 0 deletions src/session/queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ static z_result_t _z_trigger_queryables_inner(_z_session_rc_t *zsrc, _z_msg_quer
_z_queryable_infos_t *qle_info = _z_queryable_infos_svec_get(&qles, i);
qle_info->callback(&query, qle_info->arg);
}
// Send reply final message
_z_query_send_reply_final(&query);
// Clean up
_z_keyexpr_clear(&key);
#if Z_FEATURE_RX_CACHE != 1
Expand Down

0 comments on commit 4a10390

Please sign in to comment.