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: Unify return codes of osmux_batch_add() and osmux_batch_enqueue()

This way it's way easier to return the error to the caller, and the code
is easier to read.

Change-Id: Ib78c9b82b85c74be2c5e94dae7c212175244d5fa
---
M src/osmux.c
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/osmux.c b/src/osmux.c
index 801372b..bcf6e47 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -311,6 +311,7 @@
int dummy;
};

+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
static int osmux_batch_enqueue(struct msgb *msg, struct osmux_circuit *circuit,
uint8_t batch_factor)
{
@@ -325,7 +326,7 @@
return -1;

LOGP(DLMUX, LOGL_DEBUG, "Batch is full for RTP sssrc=%u\n", rtph->ssrc);
- return -1;
+ return 1;
}

llist_add_tail(&msg->list, &circuit->msg_list);
@@ -606,7 +607,7 @@
DELTA_RTP_TIMESTAMP);

/* No more room in this batch, skip padding with more clones */
- if (osmux_batch_enqueue(clone, circuit, batch_factor) < 0) {
+ if (osmux_batch_enqueue(clone, circuit, batch_factor) != 0) {
msgb_free(clone);
break;
}
@@ -668,6 +669,7 @@
talloc_free(circuit);
}

+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
static int
osmux_batch_add(struct osmux_batch *batch, uint32_t batch_factor, struct msgb *msg,
struct rtp_hdr *rtph, int ccid)
@@ -675,6 +677,7 @@
int bytes = 0, amr_payload_len;
struct osmux_circuit *circuit;
struct msgb *cur;
+ int rc;

circuit = osmux_batch_find_circuit(batch, ccid);
if (!circuit)
@@ -727,8 +730,9 @@
osmux_replay_lost_packets(circuit, rtph, batch_factor);

/* This batch is full, force batch delivery */
- if (osmux_batch_enqueue(msg, circuit, batch_factor) < 0)
- return 1;
+ rc = osmux_batch_enqueue(msg, circuit, batch_factor);
+ if (rc != 0)
+ return rc;

#ifdef DEBUG_MSG
LOGP(DLMUX, LOGL_DEBUG, "adding msg with ssrc=%u to batch\n",

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

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ib78c9b82b85c74be2c5e94dae7c212175244d5fa
Gerrit-Change-Number: 29500
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