Skip to content

Commit

Permalink
feat: remove ke from unicast undeclares
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Mar 12, 2024
1 parent 20857b3 commit 3218e18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
21 changes: 18 additions & 3 deletions src/net/primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ int8_t _z_undeclare_subscriber(_z_subscriber_t *sub) {
return _Z_ERR_ENTITY_UNKNOWN;
}
// Build the declare message to send on the wire
_z_declaration_t declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key);
_z_declaration_t declaration;
if (sub->_zn.in->val._tp._type == _Z_TRANSPORT_UNICAST_TYPE) {
declaration = _z_make_undecl_subscriber(sub->_entity_id, NULL);
} else {
declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key);
}
_z_network_message_t n_msg = _z_n_msg_make_declare(declaration);
if (_z_send_n_msg(&sub->_zn.in->val, &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) {
return _Z_ERR_TRANSPORT_TX_FAILED;
Expand Down Expand Up @@ -318,7 +323,12 @@ int8_t _z_undeclare_queryable(_z_queryable_t *qle) {
return _Z_ERR_ENTITY_UNKNOWN;
}
// Build the declare message to send on the wire
_z_declaration_t declaration = _z_make_undecl_queryable(qle->_entity_id, &q->in->val._key);
_z_declaration_t declaration;
if (qle->_zn.in->val._tp._type == _Z_TRANSPORT_UNICAST_TYPE) {
declaration = _z_make_undecl_queryable(qle->_entity_id, NULL);
} else {
declaration = _z_make_undecl_queryable(qle->_entity_id, &q->in->val._key);
}
_z_network_message_t n_msg = _z_n_msg_make_declare(declaration);
if (_z_send_n_msg(&qle->_zn.in->val, &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) {
return _Z_ERR_TRANSPORT_TX_FAILED;
Expand Down Expand Up @@ -461,7 +471,12 @@ int8_t _z_undeclare_interest(_z_session_t *zn, uint32_t interest_id) {
return _Z_ERR_ENTITY_UNKNOWN;
}
// Build the declare message to send on the wire
_z_declaration_t declaration = _z_make_undecl_interest(sintr->in->val._id, &sintr->in->val._key);
_z_declaration_t declaration;
if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) {
declaration = _z_make_undecl_interest(sintr->in->val._id, NULL);
} else {
declaration = _z_make_undecl_interest(sintr->in->val._id, &sintr->in->val._key);
}
_z_network_message_t n_msg = _z_n_msg_make_declare(declaration);
if (_z_send_n_msg(zn, &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) {
return _Z_ERR_TRANSPORT_TX_FAILED;
Expand Down
26 changes: 18 additions & 8 deletions src/protocol/definitions/declarations.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ _z_declaration_t _z_make_decl_subscriber(_Z_MOVE(_z_keyexpr_t) key, uint32_t id,
._keyexpr = _z_keyexpr_steal(key),
._ext_subinfo = {._pull_mode = pull_mode, ._reliable = reliable}}}};
}

_z_declaration_t _z_make_undecl_subscriber(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) {
return (_z_declaration_t){._tag = _Z_UNDECL_SUBSCRIBER,
._body = {._undecl_subscriber = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}};
return (_z_declaration_t){
._tag = _Z_UNDECL_SUBSCRIBER,
._body = {._undecl_subscriber = {
._id = id, ._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}};
}

_z_declaration_t _z_make_decl_queryable(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, uint32_t distance, uint8_t complete) {
return (_z_declaration_t){
._tag = _Z_DECL_QUERYABLE,
Expand All @@ -88,8 +92,10 @@ _z_declaration_t _z_make_decl_queryable(_Z_MOVE(_z_keyexpr_t) key, uint32_t id,
._ext_queryable_info = {._complete = complete, ._distance = distance}}}};
}
_z_declaration_t _z_make_undecl_queryable(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) {
return (_z_declaration_t){._tag = _Z_UNDECL_QUERYABLE,
._body = {._undecl_queryable = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}};
return (_z_declaration_t){
._tag = _Z_UNDECL_QUERYABLE,
._body = {._undecl_queryable = {
._id = id, ._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}};
}
_z_declaration_t _z_make_decl_token(_Z_MOVE(_z_keyexpr_t) key, uint32_t id) {
return (_z_declaration_t){._tag = _Z_DECL_TOKEN,
Expand All @@ -99,8 +105,10 @@ _z_declaration_t _z_make_decl_token(_Z_MOVE(_z_keyexpr_t) key, uint32_t id) {
}}};
}
_z_declaration_t _z_make_undecl_token(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) {
return (_z_declaration_t){._tag = _Z_UNDECL_TOKEN,
._body = {._undecl_token = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}};
return (_z_declaration_t){
._tag = _Z_UNDECL_TOKEN,
._body = {._undecl_token = {._id = id,
._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}};
}
_z_declaration_t _z_make_decl_interest(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, uint8_t interest_flags) {
return (_z_declaration_t){._tag = _Z_DECL_INTEREST,
Expand All @@ -111,8 +119,10 @@ _z_declaration_t _z_make_decl_interest(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, u
}}};
}
_z_declaration_t _z_make_undecl_interest(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) {
return (_z_declaration_t){._tag = _Z_UNDECL_INTEREST,
._body = {._undecl_interest = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}};
return (_z_declaration_t){
._tag = _Z_UNDECL_INTEREST,
._body = {._undecl_interest = {
._id = id, ._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}};
}
_z_declaration_t _z_make_final_interest(uint32_t id) {
return (_z_declaration_t){._tag = _Z_FINAL_INTEREST, ._body = {._final_interest = {._id = id}}};
Expand Down

0 comments on commit 3218e18

Please sign in to comment.