Add application duplication

This commit is contained in:
Quentin 2019-08-26 17:48:22 +02:00
parent a9b25c43db
commit 4cb27b1420
3 changed files with 39 additions and 3 deletions

View file

@ -15,7 +15,6 @@ struct thunder_ctx {
struct timespec prev_link_time; struct timespec prev_link_time;
}; };
void prepare(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { 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 algo_ctx* app_ctx = fdinfo->cat->app_ctx;
struct thunder_ctx* thunderc = app_ctx->misc; 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 .fmt.content.udp_metadata_thunder.deltat = 0 //@FIXME delta t must be set
}; };
buffer_append_ap (bp, &metadata); buffer_append_ap (bp, &metadata);
} }
void pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { 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) { 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; 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; return 0;
} }

View file

@ -232,6 +232,28 @@ struct buffer_packet* dup_buffer_tow(struct buffer_resources *app_ctx, struct bu
return bp_dest; 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) { struct buffer_packet* get_app_buffer(struct buffer_resources *app_ctx, void* idx) {
return g_hash_table_lookup (app_ctx->application_waiting, idx); return g_hash_table_lookup (app_ctx->application_waiting, idx);
} }

View file

@ -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_atow(struct buffer_resources* app_ctx, void* from, struct evt_core_fdinfo* to);
void mv_buffer_atof(struct buffer_resources* app_ctx, void* from); 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_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); 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); struct buffer_packet* get_write_buffer(struct buffer_resources *app_ctx, struct evt_core_fdinfo *fdinfo);