Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jan 16, 2025
1 parent 7d43a4d commit 18f82ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/net/matching.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ z_result_t _z_matching_listener_entity_undeclare(_z_session_t *zn, _z_zint_t ent
}
_z_str_intmap_iterator_next(&iter);
}
_Z_DEBUG("_z_matching_listener_entity_undeclare done");
return _Z_RES_OK;
}

Expand Down
4 changes: 4 additions & 0 deletions src/net/primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ z_result_t _z_undeclare_publisher(_z_publisher_t *pub) {
if (pub == NULL || _Z_RC_IS_NULL(&pub->_zn)) {
return _Z_ERR_ENTITY_UNKNOWN;
}
_Z_DEBUG("_z_undeclare_publisher 0");
#if Z_FEATURE_MATCHING == 1
_z_matching_listener_entity_undeclare(_Z_RC_IN_VAL(&pub->_zn), pub->_id);
#endif
// Clear publisher
_Z_DEBUG("_z_undeclare_publisher 1");
_z_write_filter_destroy(pub);
_Z_DEBUG("_z_undeclare_publisher 2");
_z_undeclare_resource(_Z_RC_IN_VAL(&pub->_zn), pub->_key._id);
_Z_DEBUG("_z_undeclare_publisher 3");
return _Z_RES_OK;
}

Expand Down
14 changes: 13 additions & 1 deletion tests/z_api_matching_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void on_drop(void* context) {
}

void test_matching_sub(bool background) {
printf("test_matching_sub: background=%d\n", background);
fprintf(stderr, "test_matching_sub: background=%d\n", background);

context_t context = {0};
_context_init(&context);
Expand Down Expand Up @@ -144,40 +144,52 @@ void test_matching_sub(bool background) {
z_closure_matching_status_move(&closure)));
}
z_sleep_s(10);
fprintf(stderr, "test_matching_sub -3\n");

z_owned_subscriber_t sub;
z_owned_closure_sample_t callback;
z_closure_sample(&callback, NULL, NULL, NULL);
assert_ok(z_declare_subscriber(z_session_loan(&s2), &sub, z_view_keyexpr_loan(&k_sub),
z_closure_sample_move(&callback), NULL));

fprintf(stderr, "test_matching_sub -2\n");
z_sleep_s(10);
_context_wait(&context, MATCH, 10);

z_subscriber_drop(z_subscriber_move(&sub));

fprintf(stderr, "test_matching_sub -1\n");
z_sleep_s(10);
fprintf(stderr, "test_matching_sub -0.2\n");
_context_wait(&context, UNMATCH, 10);
fprintf(stderr, "test_matching_sub -0.1\n");

z_publisher_drop(z_publisher_move(&pub));

fprintf(stderr, "test_matching_sub 0\n");
z_sleep_s(10);
_context_wait(&context, DROP, 10);

fprintf(stderr, "test_matching_sub 1\n");
if (!background) {
z_matching_listener_drop(z_matching_listener_move(&matching_listener));
}
fprintf(stderr, "test_matching_sub 2\n");

z_sleep_s(10);
fprintf(stderr, "test_matching_sub \n");
assert_ok(zp_stop_read_task(z_loan_mut(s1)));
assert_ok(zp_stop_read_task(z_loan_mut(s2)));
assert_ok(zp_stop_lease_task(z_loan_mut(s1)));
assert_ok(zp_stop_lease_task(z_loan_mut(s2)));

fprintf(stderr, "test_matching_sub 3\n");
z_session_drop(z_session_move(&s1));
z_session_drop(z_session_move(&s2));

fprintf(stderr, "test_matching_sub 4\n");
_context_drop(&context);
fprintf(stderr, "test_matching_sub 5\n");
}

static void _check_status(z_owned_publisher_t* pub, bool expected) {
Expand Down

0 comments on commit 18f82ef

Please sign in to comment.