Fix timeout and append bug

This commit is contained in:
Quentin 2019-08-28 18:05:56 +02:00
parent 7fdd43658c
commit f898521f15
2 changed files with 14 additions and 3 deletions

View file

@ -192,7 +192,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
struct block_info *bi = malloc(sizeof(struct block_info));
bi->i = i; bi->app_ctx = app_ctx; bi->missing = expected;
set_timeout (ctx, timeout, &bi, on_block);
set_timeout (ctx, timeout, bi, on_block);
if (ctx->verbose > 1) {
fprintf(stderr, " [algo_thunder] Set timeout on link %d of %ld ms (packets expected: %ld, seen: %ld)\n",
i, timeout, expected, thunderc->received_pkts_on_link[i]);
@ -245,6 +245,7 @@ void adapt(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buff
}
struct buffer_packet *bp_dest = inject_buffer_tow (&app_ctx->br, to_fdinfo);
dump_buffer_packet (bp_dest);
buffer_append_ap (bp_dest, ui->ap_arr_pl[i]);
main_on_udp_write(ctx, to_fdinfo);
}

View file

@ -1,7 +1,15 @@
#include "packet.h"
int ap_exists(union abstract_packet* ap) {
return ap->fmt.headers.cmd != 0;
}
int buffer_has_ap(struct buffer_packet* bp) {
return ap_exists(buffer_first_ap (bp));
}
union abstract_packet* ap_next(union abstract_packet* ap) {
if (ap->fmt.headers.flags & FLAG_READ_NEXT)
if (ap_exists (ap) && ap->fmt.headers.flags & FLAG_READ_NEXT)
return (union abstract_packet*)(&ap->raw + ap->fmt.headers.size);
return NULL;
@ -37,7 +45,9 @@ size_t buffer_full_size(struct buffer_packet* bp) {
}
union abstract_packet* buffer_append_ap(struct buffer_packet* bp, union abstract_packet* ap) {
if (buffer_has_ap (bp))
buffer_last_ap(bp)->fmt.headers.flags |= FLAG_READ_NEXT;
union abstract_packet *new_ap = buffer_last_ap(bp);
memcpy(new_ap, ap, ap->fmt.headers.size);
bp->ap_count++;