Commit 76bc7522 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add statistics about regexp purges.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3032 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent b571db1a
......@@ -95,7 +95,10 @@ BAN_Add(struct cli *cli, const char *regexp, int hash)
LOCK(&ban_mtx);
VTAILQ_INSERT_HEAD(&ban_head, b, list);
ban_start = b;
VSL_stats->n_purge++;
VSL_stats->n_purge_add++;
UNLOCK(&ban_mtx);
return (0);
}
......@@ -126,10 +129,13 @@ BAN_DestroyObj(struct object *o)
/* Check if we can purge the last ban entry */
b = VTAILQ_LAST(&ban_head, banhead);
if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0)
if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) {
VSL_stats->n_purge--;
VSL_stats->n_purge_retire++;
VTAILQ_REMOVE(&ban_head, b, list);
else
} else {
b = NULL;
}
UNLOCK(&ban_mtx);
if (b != NULL) {
free(b->ban);
......@@ -144,6 +150,7 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash)
{
struct ban *b;
struct ban * volatile b0;
unsigned tests;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(o->ban, BAN_MAGIC);
......@@ -158,7 +165,9 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash)
* a refcount on a ban somewhere in the list and we do not
* inspect the list past that ban.
*/
tests = 0;
for (b = b0; b != o->ban; b = VTAILQ_NEXT(b, list)) {
tests++;
if (!regexec(&b->regexp, b->hash ? hash : url, 0, NULL, 0))
break;
}
......@@ -167,6 +176,7 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash)
o->ban->refcount--;
if (b == o->ban) /* not banned */
b0->refcount++;
VSL_stats->n_purge_test++;
UNLOCK(&ban_mtx);
if (b == o->ban) { /* not banned */
......
......@@ -116,3 +116,8 @@ MAC_STAT(backend_req, uint64_t, 'a', "Backend requests made")
MAC_STAT(n_vcl, uint64_t, 'a', "N vcl total")
MAC_STAT(n_vcl_avail, uint64_t, 'a', "N vcl available")
MAC_STAT(n_vcl_discard, uint64_t, 'a', "N vcl discarded")
MAC_STAT(n_purge, uint64_t, 'i', "N total active purges")
MAC_STAT(n_purge_add, uint64_t, 'a', "N new purges added")
MAC_STAT(n_purge_retire, uint64_t, 'a', "N old purges deleted")
MAC_STAT(n_purge_test, uint64_t, 'a', "N purge record tests")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment