It works better when you write correct code

This commit is contained in:
Quentin Dufour 2019-03-27 18:46:48 +01:00
parent 6c276ae3c7
commit 1b0954ecca

View file

@ -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