Commit f3d13a32 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add more stats


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@328 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 01f1647a
......@@ -154,6 +154,7 @@ accept_f(int fd, short event, void *arg)
* XXX: this is probably one we should handle
* XXX: accept, emit error NNN and close
*/
VSL_stats->n_sess++;
sp = &sm->s;
sp->rd_e = &sm->e;
......@@ -242,6 +243,7 @@ vca_return_session(struct sess *sp)
} else {
if (sp->http != NULL)
http_Delete(sp->http);
VSL_stats->n_sess--;
free(sp->mem);
}
}
......
......@@ -90,10 +90,13 @@ connect_to_backend(struct vbe_conn *vc, struct backend *bp)
memset(&hint, 0, sizeof hint);
hint.ai_family = PF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
res = NULL;
error = getaddrinfo(bp->hostname,
bp->portname == NULL ? "http" : bp->portname,
&hint, &res);
if (error) {
if (res != NULL)
freeaddrinfo(res);
fprintf(stderr, "getaddrinfo: %s\n",
gai_strerror(error));
return;
......@@ -138,6 +141,7 @@ vbe_rdp(int fd, short event __unused, void *arg __unused)
if (vc->fd < 0) {
vc->vbe->nconn--;
free(vc);
VSL_stats->n_vbe_conn--;
} else {
vc->inuse = 0;
event_add(&vc->ev, NULL);
......@@ -172,6 +176,7 @@ vbe_rdf(int fd, short event __unused, void *arg)
event_del(&vc->ev);
close(vc->fd);
free(vc);
VSL_stats->n_vbe_conn--;
}
/* Backend monitoring thread -----------------------------------------*/
......@@ -220,6 +225,7 @@ VBE_GetFd(struct backend *bp, void **ptr, unsigned xid)
if (vp == NULL) {
vp = calloc(sizeof *vp, 1);
assert(vp != NULL);
VSL_stats->n_vbe++;
TAILQ_INIT(&vp->fconn);
TAILQ_INIT(&vp->bconn);
vp->ip = bp->ip;
......@@ -235,6 +241,7 @@ VBE_GetFd(struct backend *bp, void **ptr, unsigned xid)
AZ(pthread_mutex_unlock(&vbemtx));
} else {
vc = calloc(sizeof *vc, 1);
VSL_stats->n_vbe_conn++;
assert(vc != NULL);
vc->vbe = vp;
vc->fd = -1;
......
......@@ -287,6 +287,7 @@ FetchSession(struct worker *w, struct sess *sp)
cls = 0;
sbuf_finish(w->sb);
sp->obj->header = strdup(sbuf_data(w->sb));
VSL_stats->n_header++;
vca_write_obj(w, sp);
......
......@@ -33,6 +33,7 @@ HSH_Lookup(struct worker *w, struct http *h)
assert(w->nobjhead != NULL);
TAILQ_INIT(&w->nobjhead->objects);
AZ(pthread_mutex_init(&w->nobjhead->mtx, NULL));
VSL_stats->n_objecthead++;
}
if (w->nobj == NULL) {
w->nobj = calloc(sizeof *w->nobj, 1);
......@@ -40,6 +41,7 @@ HSH_Lookup(struct worker *w, struct http *h)
w->nobj->busy = 1;
TAILQ_INIT(&w->nobj->store);
AZ(pthread_cond_init(&w->nobj->cv, NULL));
VSL_stats->n_object++;
}
assert(http_GetURL(h, &b));
......@@ -110,7 +112,10 @@ HSH_Deref(struct object *o)
if (o == NULL)
return;
free(o->header);
if (o->header != NULL) {
free(o->header);
VSL_stats->n_header--;
}
AZ(pthread_cond_destroy(&o->cv));
TAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
......@@ -118,12 +123,14 @@ HSH_Deref(struct object *o)
st->stevedore->free(st);
}
free(o);
VSL_stats->n_object--;
/* Drop our ref on the objhead */
if (hash->deref(oh))
return;
assert(TAILQ_EMPTY(&oh->objects));
AZ(pthread_mutex_destroy(&oh->mtx));
VSL_stats->n_objecthead--;
free(oh);
}
......
......@@ -53,6 +53,7 @@ http_New(void)
hp = calloc(sizeof *hp, 1);
assert(hp != NULL);
VSL_stats->n_http++;
hp->s = malloc(http_bufsize);
assert(hp->s != NULL);
......@@ -74,6 +75,7 @@ http_Delete(struct http *hp)
free(hp->hdr);
free(hp->s);
free(hp);
VSL_stats->n_http--;
}
/*--------------------------------------------------------------------*/
......@@ -369,10 +371,12 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
unsigned l;
assert(hp != NULL);
VSL(SLT_Debug, fd, "Recv t %u v %u", hp->t - hp->s, hp->v - hp->s);
if (hp->t > hp->s && hp->t < hp->v) {
l = hp->v - hp->t;
memmove(hp->s, hp->t, l);
hp->v = hp->s + l;
hp->t = hp->s;
if (http_header_complete(hp)) {
func(arg, 1);
return;
......
......@@ -22,6 +22,7 @@
#include <sys/socket.h>
#include "libvarnish.h"
#include "shmlog.h"
#include "cache.h"
#define MINPAGES 128
......@@ -284,6 +285,7 @@ alloc_smf(struct smf_sc *sc, size_t bytes)
/* Split from front */
sp2 = malloc(sizeof *sp2);
assert(sp2 != NULL);
VSL_stats->n_smf++;
*sp2 = *sp;
sp->offset += bytes;
......@@ -320,6 +322,7 @@ free_smf(struct smf *sp)
TAILQ_REMOVE(&sc->order, sp2, order);
TAILQ_REMOVE(&sc->free, sp2, status);
free(sp2);
VSL_stats->n_smf--;
}
sp2 = TAILQ_PREV(sp, smfhead, order);
......@@ -331,6 +334,7 @@ free_smf(struct smf *sp)
sp2->age = sp->age;
TAILQ_REMOVE(&sc->order, sp, order);
free(sp);
VSL_stats->n_smf--;
TAILQ_REMOVE(&sc->free, sp2, status);
sp = sp2;
}
......@@ -359,6 +363,7 @@ trim_smf(struct smf *sp, size_t bytes)
assert(bytes > 0);
sp2 = malloc(sizeof *sp2);
assert(sp2 != NULL);
VSL_stats->n_smf++;
*sp2 = *sp;
sp2->size -= bytes;
......@@ -381,6 +386,7 @@ new_smf(struct smf_sc *sc, unsigned char *ptr, off_t off, size_t len)
sp = calloc(sizeof *sp, 1);
assert(sp != NULL);
VSL_stats->n_smf++;
sp->sc = sc;
......
......@@ -9,3 +9,13 @@ MAC_STAT(cache_miss, uint64_t, "u", "Cache misses")
MAC_STAT(backend_conn, uint64_t, "u", "Backend connections initiated")
MAC_STAT(backend_recycle, uint64_t, "u", "Backend connections recyles")
MAC_STAT(n_sess, uint64_t, "u", "N struct sess");
MAC_STAT(n_object, uint64_t, "u", "N struct object");
MAC_STAT(n_objecthead, uint64_t, "u", "N struct objecthead");
MAC_STAT(n_header, uint64_t, "u", "N struct header");
MAC_STAT(n_smf, uint64_t, "u", "N struct smf");
MAC_STAT(n_http, uint64_t, "u", "N struct http");
MAC_STAT(n_vbe, uint64_t, "u", "N struct vbe");
MAC_STAT(n_vbe_conn, uint64_t, "u", "N struct vbe_conn");
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