diff --git a/src/net/matching.c b/src/net/matching.c index 8ef35f5da..56603fe0a 100644 --- a/src/net/matching.c +++ b/src/net/matching.c @@ -80,10 +80,12 @@ _z_matching_listener_t _z_matching_listener_declare(_z_session_rc_t *zn, const _ z_result_t _z_matching_listener_entity_undeclare(_z_session_t *zn, _z_zint_t entity_id) { _z_matching_listener_intmap_iterator_t iter = _z_matching_listener_intmap_iterator_make(&zn->_matching_listeners); - while (_z_matching_listener_intmap_iterator_next(&iter)) { + bool has_next = _z_matching_listener_intmap_iterator_next(&iter); + while (has_next) { size_t key = _z_matching_listener_intmap_iterator_key(&iter); _z_matching_listener_state_t *listener = _z_matching_listener_intmap_iterator_value(&iter); _Z_DEBUG("_z_matching_listener_entity_undeclare: listener=%p", (void *)listener); + has_next = _z_matching_listener_intmap_iterator_next(&iter); if (listener->entity_id == entity_id) { _Z_DEBUG("_z_matching_listener_entity_undeclare: entity=%i, listener=%i", (int)entity_id, (int)key); _z_remove_interest(zn, listener->interest_id); diff --git a/tests/z_api_matching_test.c b/tests/z_api_matching_test.c index 8c09ad7ed..0a9c621c7 100644 --- a/tests/z_api_matching_test.c +++ b/tests/z_api_matching_test.c @@ -128,7 +128,6 @@ void test_matching_sub(bool background) { z_owned_publisher_t pub; assert_ok(z_declare_publisher(z_session_loan(&s1), &pub, z_view_keyexpr_loan(&k_pub), NULL)); - z_sleep_s(10); z_owned_closure_matching_status_t closure; z_closure_matching_status(&closure, on_receive, on_drop, (void*)(&context)); diff --git a/tests/z_collections_test.c b/tests/z_collections_test.c index 69183050b..c49121569 100644 --- a/tests/z_collections_test.c +++ b/tests/z_collections_test.c @@ -361,12 +361,13 @@ void int_map_iterator_deletion_test(void) { _z_str_intmap_insert(&map, 40, _z_str_clone("D")); _z_str_intmap_iterator_t iter = _z_str_intmap_iterator_make(&map); + _z_str_intmap_iterator_next(&iter); for (size_t s = 4; s != 0; s--) { assert(s == _z_str_intmap_len(&map)); - _z_str_intmap_iterator_next(&iter); size_t key = _z_str_intmap_iterator_key(&iter); assert(strlen(_z_str_intmap_iterator_value(&iter)) == 1); _z_str_intmap_remove(&map, key); + _z_str_intmap_iterator_next(&iter); } _z_str_intmap_clear(&map); }