From 516b2707b5ad91ad982d35109383b02596d92282 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 24 May 2019 11:04:37 +0200 Subject: [PATCH] Improve debug --- src/algo_rr.c | 6 ++++-- src/proxy.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/algo_rr.c b/src/algo_rr.c index f1ee2bd..177e598 100644 --- a/src/algo_rr.c +++ b/src/algo_rr.c @@ -182,14 +182,14 @@ int algo_rr_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct rr_ctx* rr = app_ctx->misc; if (bp->ip.ap.fmt.headers.cmd == CMD_CLEAR) { - if (ctx->verbose) printf("Received a CLEAR packet of size %d\n", bp->ip.ap.fmt.headers.size); + if (ctx->verbose > 1) fprintf(stderr, " [algo/rr] Received a CLEAR packet of size %d on URL %s\n", bp->ip.ap.fmt.headers.size, fdinfo->url); // 1. Register packet in our queue rr_pkt_register(ctx, fdinfo, bp); // 2. Process queue rr_pkt_unroll (ctx, app_ctx); } else if (bp->ip.ap.fmt.headers.cmd == CMD_HEALTH) { - if (ctx->verbose) printf("Received a HEALTH packet of size %d\n", bp->ip.ap.fmt.headers.size); + if (ctx->verbose > 1) fprintf(stderr, " [algo/rr] Received a HEALTH packet of size %d on URL %s\n", bp->ip.ap.fmt.headers.size, fdinfo->url); rr_pkt_manage_links(ctx, fdinfo, bp); } @@ -203,6 +203,8 @@ int algo_rr_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo uint16_t min_pkt; char url[255]; + if (ctx->verbose > 1) fprintf(stderr, " [algo/rr] Read a UDP packet on URL %s\n", fdinfo->url); + // 1. Prepare RR state and packet values struct timespec curr; int secs, nsecs; diff --git a/src/proxy.c b/src/proxy.c index 60fe7c7..5eae61b 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -43,17 +43,17 @@ int main_on_tcp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { struct algo_ctx* app_ctx = fdinfo->cat->app_ctx; int read_res = FDS_READY; - // 1. Get current read buffer OR a new read buffer OR subscribe to be notified later + if (ctx->verbose > 1) fprintf(stderr, " [proxy] Get current read buffer OR a new read buffer OR subscribe to be notified later\n"); if ((bp = get_read_buffer(app_ctx, fdinfo)) == NULL) return 1; - // 2. Try to read a whole packet in the buffer + if (ctx->verbose > 1) fprintf(stderr, " [proxy] Try to read a whole packet in the buffer\n"); while (bp->mode == BP_READING) { read_res = read_packet_from_tcp (fdinfo->fd, bp); if (read_res == FDS_ERR) goto co_error; if (read_res == FDS_AGAIN) return 1; } - // 3. Logic on packet + if (ctx->verbose > 1) fprintf(stderr, " [proxy] Call logic on packet\n"); return app_ctx->desc->on_stream(ctx, fdinfo, bp); co_error: