From: Amaury Denoyelle Date: Thu, 19 Nov 2026 13:35:34 +0000 (+0100) Subject: BUG/MINOR: ncbuf/test: remove unnecessary delay in random insert X-Git-Url: https://git.kaiwu.me/http/ngx_http_auth_basic_module.html?a=commitdiff_plain;h=184753f53b04b90503898a030df1113a76c81ad4;p=haproxy.git BUG/MINOR: ncbuf/test: remove unnecessary delay in random insert A delay is used for better readability when the buffer content is displayed on each iteration during the random insert test. However, this delay also applied when nothing was printed. This renders the test artificially long. Thus, removes the delay when print is not requested so that the test can run as fast as possible. This should be backported up to 2.6. --- diff --git a/src/ncbuf.c b/src/ncbuf.c index 0a94c4b46..4b62ef453 100644 --- a/src/ncbuf.c +++ b/src/ncbuf.c @@ -773,6 +773,15 @@ static void ncbuf_print_buf(struct ncbuf *b, ncb_sz_t len, getchar(); } +static void ncbuf_print_buf_delay(struct ncbuf *b, ncb_sz_t len, + unsigned char *area, int line, int delay) +{ + if (ncb_print) { + ncbuf_print_buf(b, len, area, line); + usleep(delay); + } +} + static struct ncbuf b; static unsigned char *bufarea = NULL; static ncb_sz_t bufsize = 16384; @@ -909,8 +918,7 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) ret = ncb_add(&b, roff->off, data0, roff->len, NCB_ADD_COMPARE); BUG_ON(ret == NCB_RET_DATA_REJ); - ncbuf_print_buf(&b, bufsize, bufarea, __LINE__); - usleep(print_delay); + ncbuf_print_buf_delay(&b, bufsize, bufarea, __LINE__, print_delay); } fprintf(stderr, "buf full, prepare for reverse random\n"); @@ -925,8 +933,7 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) if (!full) { ret = ncb_add(&b, roff->off, data0, roff->len, NCB_ADD_COMPARE); BUG_ON(ret == NCB_RET_DATA_REJ); - ncbuf_print_buf(&b, bufsize, bufarea, __LINE__); - usleep(print_delay); + ncbuf_print_buf_delay(&b, bufsize, bufarea, __LINE__, print_delay); } roff_tmp = roff->next;