pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29523 )
Change subject: osmux: join osmux_xfrm_input_open_circuit() and osmux_batch_add_circuit() ......................................................................
osmux: join osmux_xfrm_input_open_circuit() and osmux_batch_add_circuit()
There's no real use in having it split, it just makes it more difficult to extend since extra prams must be passed over 2 functions. In fact, the duplicity of "struct osmux_in_handle" and "struct osmux_batch" as its ->internal_data should go away in the future.
Change-Id: Ie4c6b55827ac27bcdfbe1b14fb238f5873243000 --- M src/osmux.c 1 file changed, 25 insertions(+), 33 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/23/29523/1
diff --git a/src/osmux.c b/src/osmux.c index ec5712d..30661d2 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -645,38 +645,6 @@ return NULL; }
-static struct osmux_circuit * -osmux_batch_add_circuit(struct osmux_batch *batch, int ccid, int dummy, - uint8_t batch_factor) -{ - struct osmux_circuit *circuit; - - circuit = osmux_batch_find_circuit(batch, ccid); - if (circuit != NULL) { - LOGP(DLMUX, LOGL_ERROR, "circuit %u already exists!\n", ccid); - return NULL; - } - - circuit = talloc_zero(osmux_ctx, struct osmux_circuit); - if (circuit == NULL) { - LOGP(DLMUX, LOGL_ERROR, "OOM on circuit %u\n", ccid); - return NULL; - } - - circuit->ccid = ccid; - INIT_LLIST_HEAD(&circuit->msg_list); - llist_add_tail(&circuit->head, &batch->circuit_list); - - if (dummy) { - circuit->dummy = dummy; - batch->ndummy++; - if (!osmo_timer_pending(&batch->timer)) - osmo_timer_schedule(&batch->timer, 0, - batch_factor * DELTA_RTP_MSG); - } - return circuit; -} - static void osmux_batch_del_circuit(struct osmux_batch *batch, struct osmux_circuit *circuit) { if (circuit->dummy) @@ -876,8 +844,32 @@ int dummy) { struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; + struct osmux_circuit *circuit;
- return osmux_batch_add_circuit(batch, ccid, dummy, h->batch_factor) ? 0 : -1; + circuit = osmux_batch_find_circuit(batch, ccid); + if (circuit != NULL) { + LOGP(DLMUX, LOGL_ERROR, "circuit %u already exists!\n", ccid); + return -1; + } + + circuit = talloc_zero(osmux_ctx, struct osmux_circuit); + if (circuit == NULL) { + LOGP(DLMUX, LOGL_ERROR, "OOM on circuit %u\n", ccid); + return -1; + } + + circuit->ccid = ccid; + INIT_LLIST_HEAD(&circuit->msg_list); + llist_add_tail(&circuit->head, &batch->circuit_list); + + if (dummy) { + circuit->dummy = dummy; + batch->ndummy++; + if (!osmo_timer_pending(&batch->timer)) + osmo_timer_schedule(&batch->timer, 0, + h->batch_factor * DELTA_RTP_MSG); + } + return 0; }
void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid)