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
This commit is contained in:
Pau Espin 2022-09-29 12:01:30 +02:00 committed by pespin
parent 3e6f4d12c9
commit 11f725ae78
1 changed files with 25 additions and 33 deletions

View File

@ -645,38 +645,6 @@ osmux_batch_find_circuit(struct osmux_batch *batch, int ccid)
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 osmux_xfrm_input_open_circuit(struct osmux_in_handle *h, int ccid,
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)