From 1b0954ecca618862d7c080858b3bd230bf7c8d93 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 27 Mar 2019 18:46:48 +0100 Subject: [PATCH] It works better when you write correct code --- src/algo_rr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/algo_rr.c b/src/algo_rr.c index 737fdd4..216e430 100644 --- a/src/algo_rr.c +++ b/src/algo_rr.c @@ -186,13 +186,19 @@ void rr_pkt_register(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, // 5. We queue the packet if (rr->real[idx_real].on && rr->real[idx_real].id != bp->ip.ap.str.id) { - fprintf(stderr, "Real array is full, BUG\n"); + fprintf(stderr, "Real array is full for id=%d, idx=%d, BUG: [\n", bp->ip.ap.str.id, idx_real); + for (int i = 0; i < PACKET_BUFFER_SIZE; i++) { + printf("\t%d => %d\n", i, rr->real[i].on); + } + printf("]\n"); exit(EXIT_FAILURE); } else if (!rr->real[idx_real].on) { rr->real[idx_real].on = 1; + rr->real[idx_real].id = bp->ip.ap.str.id; rr->real[idx_real].idx = idx_real; rr->real[idx_real].link_fd = fdinfo->fd; mv_buffer_rtoa(app_ctx, fdinfo, &rr->real[idx_real].idx); + //printf("%d is added to real as %d\n", bp->ip.ap.str.id, idx_real); } else { fprintf(stdout, "Packet %d already received (current: %d)\n", bp->ip.ap.str.id, rr->recv_id); mv_buffer_wtof (app_ctx, fdinfo); @@ -212,6 +218,7 @@ void rr_deliver(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct struct buffer_packet* bp = get_app_buffer (app_ctx, &dp->idx); int idx_real = bp->ip.ap.str.id % PACKET_BUFFER_SIZE; rr->real[idx_real].on = 0; + //printf("%d is removed from real as %d\n", bp->ip.ap.str.id, idx_real); //printf("Selected url %s for pkt %d to be delivered\n", fdinfo->url, bp->ip.ap.str.id); // 3. We update our cursor