Skip to content

First packet sent from receiver using balancing is always lost

rist_sender_send_data_balanced (udp.c) always fails to send the very first package when not using weight=0 (duplicate). selected_peer_by_weight will always be NULL for the first packet. For consecutive packets a peer will successfully be chosen. The problem appears even if there is just one single peer. When configuring weight=0 to all peers all works well.

The problem seems to be that w_count is not properly initialized when creating a peer, it is initialized to 0. A fix for this problem is to set w_count to the configured weight in rist_sender_peer_create.

diff --git a/src/rist.c b/src/rist.c
index 88d07f1..86c21b1 100644
--- a/src/rist.c
+++ b/src/rist.c
@@ -874,6 +874,7 @@ static int rist_sender_peer_create(struct rist_sender *ctx,
        // TODO: Validate config data (virt_dst_port != 0 for example)
 
        newpeer->is_data = true;
+       newpeer->w_count = config->weight;
        peer_append(newpeer);
 
        if (ctx->common.profile == RIST_PROFILE_SIMPLE)