From adf2767763cc1b90b4d97c8e59f9a94a9ae9c758 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sat, 9 May 2026 20:24:49 +0100 Subject: [PATCH] Additional commentary on total_written and rate limiting. --- src/pv/loop.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pv/loop.c b/src/pv/loop.c index 0377f45..1ea865d 100644 --- a/src/pv/loop.c +++ b/src/pv/loop.c @@ -639,6 +639,16 @@ int pv_main_loop(pvstate_t state) return state->status.exit_status; } + /* + * Increment the total_written counter (lines or bytes + * depending on line mode) by the amount written. + * + * If rate limiting is active, subtract the amount written + * from the target amount to transfer. Whatever + * (fractional) value is left will carry over to the next + * loop iteration so that the transfer rate will average out + * to the requested rate. + */ if (state->control.linemode) { state->transfer.total_written += lineswritten; if (state->control.rate_limit_active)