diff --git a/libs/openzap/src/zap_io.c b/libs/openzap/src/zap_io.c index a88f4f661e..2987164c69 100644 --- a/libs/openzap/src/zap_io.c +++ b/libs/openzap/src/zap_io.c @@ -695,11 +695,6 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, z } for(;;) { - span = &globals.spans[j]; - if (!zap_test_flag(span, ZAP_SPAN_CONFIGURED)) { - goto next_loop; - } - if (direction == ZAP_TOP_DOWN) { if (j > span_max) { break; @@ -709,6 +704,11 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, z break; } } + + span = &globals.spans[j]; + if (!zap_test_flag(span, ZAP_SPAN_CONFIGURED)) { + goto next_loop; + } if (direction == ZAP_TOP_DOWN) { i = 1;