pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved
osmux: Early return on error or batch full during osmux_replay_lost_packets()

If there's an error while replaying lost packets, return the error to
the caller.
If the batch is found full, early return indicating so, there's no need
to continue flow calling osmux_batch_enqueue() in osmux_batch_add()
again.

Change-Id: I62f494d2b2e7903a6683f6dea00781bb721a3d41
---
M src/osmux.c
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/osmux.c b/src/osmux.c
index bcf6e47..2a5dcc9 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -560,23 +560,24 @@
return amr_payload_len;
}

-static void osmux_replay_lost_packets(struct osmux_circuit *circuit,
+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
+static int osmux_replay_lost_packets(struct osmux_circuit *circuit,
struct rtp_hdr *cur_rtph, int batch_factor)
{
int16_t diff;
struct msgb *last;
struct rtp_hdr *rtph;
- int i;
+ int i, rc;

/* Have we seen any RTP packet in this batch before? */
if (llist_empty(&circuit->msg_list))
- return;
+ return 0;

/* Get last RTP packet seen in this batch */
last = llist_entry(circuit->msg_list.prev, struct msgb, list);
rtph = osmo_rtp_get_hdr(last);
if (rtph == NULL)
- return;
+ return -1;

diff = ntohs(cur_rtph->sequence) - ntohs(rtph->sequence);

@@ -584,6 +585,7 @@
if (diff > 16)
diff = 16;

+ rc = 0;
/* If diff between last RTP packet seen and this one is > 1,
* then we lost several RTP packets, let's replay them.
*/
@@ -607,13 +609,15 @@
DELTA_RTP_TIMESTAMP);

/* No more room in this batch, skip padding with more clones */
- if (osmux_batch_enqueue(clone, circuit, batch_factor) != 0) {
+ rc = osmux_batch_enqueue(clone, circuit, batch_factor);
+ if (rc != 0) {
msgb_free(clone);
- break;
+ return rc;
}

LOGP(DLMUX, LOGL_ERROR, "adding cloned RTP\n");
}
+ return rc;
}

static struct osmux_circuit *
@@ -727,7 +731,9 @@
return 1;

/* Handle RTP packet loss scenario */
- osmux_replay_lost_packets(circuit, rtph, batch_factor);
+ rc = osmux_replay_lost_packets(circuit, rtph, batch_factor);
+ if (rc != 0)
+ return rc;

/* This batch is full, force batch delivery */
rc = osmux_batch_enqueue(msg, circuit, batch_factor);

To view, visit change 29501. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I62f494d2b2e7903a6683f6dea00781bb721a3d41
Gerrit-Change-Number: 29501
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged