authorSergey Poznyakoff <>2016-02-08 11:16:39 (GMT)
committer Sergey Poznyakoff <>2016-02-08 11:16:39 (GMT)
commit067d63d298a15810171555f7f0acf96fb1946667 (patch) (side-by-side diff)
parentf490124e04a9dda412d1979ca9e3e7a51f7ab8d3 (diff)
Update the docs.
Diffstat (more/less context) (ignore whitespace changes)
2 files changed, 59 insertions, 23 deletions
diff --git a/src/tbf.c b/src/tbf.c
index 8fe3870..85dd608 100644
--- a/src/tbf.c
+++ b/src/tbf.c
@@ -196,7 +196,7 @@ tree_delete_node_unlocked(struct tree *tree, struct node *node)
node->child[CHILD_LEFT]->parent = parent;
} else {
/* Node has both subtrees. Find the largest value in the
- right subtree */
+ left subtree */
struct node *p;
for (p = node->child[CHILD_LEFT]; p->child[CHILD_RIGHT];
p = p->child[CHILD_RIGHT])
@@ -836,7 +836,7 @@ tbf_release_tree(struct tree **t)
static void
if (tbf_dump_file_name) {
struct tree *t = tbf_get_tree();
diff --git a/src/vmod-tbf.3 b/src/vmod-tbf.3
index 8af8b65..626341c 100644
--- a/src/vmod-tbf.3
+++ b/src/vmod-tbf.3
@@ -13,7 +13,7 @@
.\" You should have received a copy of the GNU General Public License
.\" along with vmod-tbf. If not, see <>.
-.TH VMOD-TBF 1 "January 26, 2016" "VMOD-TBF" "User Reference"
+.TH VMOD-TBF 1 "February 8, 2016" "VMOD-TBF" "User Reference"
vmod-tbf \- token bucket filtering for Varnish
@@ -23,14 +23,22 @@ vmod-tbf \- token bucket filtering for Varnish
.BI "BOOL tbf.check(STRING " key ", STRING " rate ");"
-.BI "VOID tbf.debug(INT " level ");"
.BI "VOID tbf.dump(STRING " file ");"
+.BI "VOID tbf.dump_at_exit(STRING " file ");"
+.BI "VOID tbf.load(STRING " file ");"
.BI "VOID tbf.gc(DURATION " interval ");"
.BI "VOID tbf.set_gc_interval(DURATION " interval ");"
+.BI "VOID tbf.debug(INT " level ");"
+.BI "VOID tbf.log_tree(INT " prio ");"
+.BI "VOID tbf.log_stats(INT " prio ");"
.BI "REAL tbf.getla(INT " sample ");"
.BI "INT tbf.systime();"
@@ -138,36 +146,64 @@ function with the interval as its argument.
The function
.B tbf.dump
-dumps entire tree to the disk file.
+dumps entire tree to the disk file. The function
+.B tbf.load
+loads the named dump file into the tree.
The function
-.B tbf.debug
-sets the debug level.
+.B tbf.dump_at_exit
+configures the module to dump the tree before
+.B varnishd
+terminates. Use this to keep the \fBtbf\fR state across
+\fBvarnishd\fR restarts. For example:
+sub vcl_init {
+ tbf.load("/var/run/tbf.dump");
+ tbf.dump_at_exit("/var/run/tbf.dump");
+.SS Debugging
+.BI "VOID tbf.debug(INT " level ");"
+Sets the debug verbosity level. Meaningful argument values are
+\fB0\fR (no debugging info) to \fB2\fR (maximum verbosity).
+.BI "VOID tbf.log_tree(INT " prio ");"
+Logs the content of the \fBtbf\fR tree to \fBsyslog\fR priority
+\fIprio\fR. Note that this can produce extremely big amounts of info.
+.BI "VOID tbf.log_stats(INT " prio ");"
+Logs the tree statistics to \fBsyslog\fR priority \fIprio\fR. The
+following information is logged: total number of nodes in tree, number
+of leaves, shortest, longest and average paths.
.SS Other functions
Several functions are provided that do not exactly belong to the
TBF algorithm, but which may come useful when implementing rate
-The \fBtbf.getla\fR function returns the system load average. Its
-argument identifies the interval for which to compute it: 1, 5 or
-15 minutes.
-The \fBtbf.systime\fR function returns the current time of day as the
-number of seconds since the Epoch (1970-01-01 00:00:00 UTC).
-The \fBtbf.strftime\fR function formats the \fBtimestamp\fR according
-to the specification in \fBformat\fR. See
+.BI "REAL tbf.getla(INT " sample ");"
+Returns the system load average. The argument identifies interval
+for which to compute it: 1, 5 or 15 minutes.
+.BI "INT tbf.systime();"
+Returns the current time of day as the number of seconds since the
+Epoch (1970-01-01 00:00:00 UTC).
+.BI "STRING tbf.strftime(STRING " format ", INT " timestamp ");"
+Function formats the \fItimestamp\fR according to the specification in
+\fIformat\fR. See
.BR strftime (3),
for a description of available formats. For example, the following
-statements assigns the current year to the \f(CWX\-Year\fR header:
+statement assigns the current year to the \f(CWX\-Year\fR header:
set req.http.X-Year = tbf.strftime("%Y", systime());
-The \fBtbf.sleep\fR function suspends execution for a specified amount
-of time.
+.BI "VOID tbf.sleep(DURATION " time ");"
+Suspends execution for a specified amount of time.
.\" The MANCGI variable is set by man.cgi script on Ulysses.
.\" The file contains the default DOWNLOAD section

Return to:

Send suggestions and report system problems to the System administrator.