From 4cb27b14209abca2804a58339656e520b567a986 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 26 Aug 2019 17:48:22 +0200 Subject: [PATCH] Add application duplication --- src/algo_thunder.c | 19 ++++++++++++++++--- src/algo_utils.c | 22 ++++++++++++++++++++++ src/algo_utils.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/algo_thunder.c b/src/algo_thunder.c index faaedb0..315a4cb 100644 --- a/src/algo_thunder.c +++ b/src/algo_thunder.c @@ -15,7 +15,6 @@ struct thunder_ctx { struct timespec prev_link_time; }; - void prepare(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { struct algo_ctx* app_ctx = fdinfo->cat->app_ctx; struct thunder_ctx* thunderc = app_ctx->misc; @@ -29,11 +28,11 @@ void prepare(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct bu .fmt.content.udp_metadata_thunder.deltat = 0 //@FIXME delta t must be set }; buffer_append_ap (bp, &metadata); - } void pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { + } int schedule(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { @@ -106,8 +105,22 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc thunderc->selected_link = UINT8_MAX - 1; } -int algo_thunder_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { +void classify() { +} + +void unpad() { + +} + +void adapt() { + +} + +int algo_thunder_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { + classify(); + unpad(); + adapt(); return 0; } diff --git a/src/algo_utils.c b/src/algo_utils.c index c17b60a..6b5c301 100644 --- a/src/algo_utils.c +++ b/src/algo_utils.c @@ -232,6 +232,28 @@ struct buffer_packet* dup_buffer_tow(struct buffer_resources *app_ctx, struct bu return bp_dest; } +struct buffer_packet* dup_buffer_toa(struct buffer_resources *app_ctx, struct buffer_packet* bp, void* to) { + GQueue* q; + + // 1. We get a free buffer + struct buffer_packet* bp_dest = g_queue_pop_head(app_ctx->free_buffer); + if (bp_dest == NULL) { + debug_buffer(app_ctx, to); + return NULL; + } + + // 2. We duplicate the data + memcpy(bp_dest, bp, sizeof(struct buffer_packet)); + + // 3. We put the data + if (g_hash_table_contains(app_ctx->application_waiting, to)) { + fprintf(stderr, "Data already exists for this entry\n"); + exit(EXIT_FAILURE); + } + g_hash_table_insert(app_ctx->application_waiting, to, bp_dest); + return bp_dest; +} + struct buffer_packet* get_app_buffer(struct buffer_resources *app_ctx, void* idx) { return g_hash_table_lookup (app_ctx->application_waiting, idx); } diff --git a/src/algo_utils.h b/src/algo_utils.h index 275923d..ab53795 100644 --- a/src/algo_utils.h +++ b/src/algo_utils.h @@ -24,6 +24,7 @@ void mv_buffer_rtoa(struct buffer_resources* app_ctx, struct evt_core_fdinfo* fr void mv_buffer_atow(struct buffer_resources* app_ctx, void* from, struct evt_core_fdinfo* to); void mv_buffer_atof(struct buffer_resources* app_ctx, void* from); struct buffer_packet* dup_buffer_tow(struct buffer_resources* app_ctx, struct buffer_packet* bp, struct evt_core_fdinfo* to); +struct buffer_packet* dup_buffer_toa(struct buffer_resources* app_ctx, struct buffer_packet* bp, void* to); guint write_queue_len(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo); struct buffer_packet* get_write_buffer(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo);