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);
}
/* 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);
{
struct ban *b;
struct ban * volatile b0;
+ unsigned tests;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(o->ban, BAN_MAGIC);
* 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;
}
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 */
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")