coarse_timer_wakeup tracks when the next timer-driven task will occur.
If a user issues `bytecount n` via the management interface, but the
next scheduled wakeup is more than n seconds away, bandwidth logging
will be delayed until that timer fires.
To ensure timely logging, reset the timer whenever a new `bytecount`
command is received. This guarantees that logging begins exactly n
seconds after the command, matching the user-defined interval.
Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250902160050.18640-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228306/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -514,6 +514,28 @@ man_bytecount(struct management *man, const int update_seconds) |
| 514 | 514 |
man->connection.bytecount_update_seconds = 0; |
| 515 | 515 |
event_timeout_clear(&man->connection.bytecount_update_interval); |
| 516 | 516 |
} |
| 517 |
+ |
|
| 518 |
+ /* The newly received bytecount interval may be sooner than the existing |
|
| 519 |
+ * coarse timer wakeup. Reset the timer to ensure it fires at the correct, |
|
| 520 |
+ * earlier time. |
|
| 521 |
+ */ |
|
| 522 |
+ if (man->persist.callback.arg) |
|
| 523 |
+ {
|
|
| 524 |
+ struct context *c; |
|
| 525 |
+ |
|
| 526 |
+ if (man->settings.flags & MF_SERVER) |
|
| 527 |
+ {
|
|
| 528 |
+ struct multi_context *m = man->persist.callback.arg; |
|
| 529 |
+ c = &m->top; |
|
| 530 |
+ } |
|
| 531 |
+ else |
|
| 532 |
+ {
|
|
| 533 |
+ c = man->persist.callback.arg; |
|
| 534 |
+ } |
|
| 535 |
+ |
|
| 536 |
+ reset_coarse_timers(c); |
|
| 537 |
+ } |
|
| 538 |
+ |
|
| 517 | 539 |
msg(M_CLIENT, "SUCCESS: bytecount interval changed"); |
| 518 | 540 |
} |
| 519 | 541 |
|