r328 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Wed Jul 5 15:13:56 CEST 2006


Author: phk
Date: 2006-07-05 15:13:56 +0200 (Wed, 05 Jul 2006)
New Revision: 328

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/storage_file.c
   trunk/varnish-cache/include/stat_field.h
Log:
Add more stats


Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -154,6 +154,7 @@
 				 * 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 @@
 	} else {
 		if (sp->http != NULL)
 			http_Delete(sp->http);
+		VSL_stats->n_sess--;
 		free(sp->mem);
 	}
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -90,10 +90,13 @@
 	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 @@
 	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 @@
 	event_del(&vc->ev);
 	close(vc->fd);
 	free(vc);
+	VSL_stats->n_vbe_conn--;
 }
 
 /* Backend monitoring thread -----------------------------------------*/
@@ -220,6 +225,7 @@
 	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 @@
 		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;

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -287,6 +287,7 @@
 		cls = 0;
 	sbuf_finish(w->sb);
 	sp->obj->header = strdup(sbuf_data(w->sb));
+	VSL_stats->n_header++;
 
 	vca_write_obj(w, sp);
 

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -33,6 +33,7 @@
 		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 @@
 		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 @@
 	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 @@
 		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);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -53,6 +53,7 @@
 
 	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 @@
 	free(hp->hdr);
 	free(hp->s);
 	free(hp);
+	VSL_stats->n_http--;
 }
 
 /*--------------------------------------------------------------------*/
@@ -369,10 +371,12 @@
 	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;

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-05 13:13:56 UTC (rev 328)
@@ -22,6 +22,7 @@
 #include <sys/socket.h>
 
 #include "libvarnish.h"
+#include "shmlog.h"
 #include "cache.h"
 
 #define MINPAGES		128
@@ -284,6 +285,7 @@
 	/* Split from front */
 	sp2 = malloc(sizeof *sp2);
 	assert(sp2 != NULL);
+	VSL_stats->n_smf++;
 	*sp2 = *sp;
 
 	sp->offset += bytes;
@@ -320,6 +322,7 @@
 		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 @@
 		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 @@
 	assert(bytes > 0);
 	sp2 = malloc(sizeof *sp2);
 	assert(sp2 != NULL);
+	VSL_stats->n_smf++;
 	*sp2 = *sp;
 
 	sp2->size -= bytes;
@@ -381,6 +386,7 @@
 
 	sp = calloc(sizeof *sp, 1);
 	assert(sp != NULL);
+	VSL_stats->n_smf++;
 
 	sp->sc = sc;
 

Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h	2006-07-05 13:09:01 UTC (rev 327)
+++ trunk/varnish-cache/include/stat_field.h	2006-07-05 13:13:56 UTC (rev 328)
@@ -9,3 +9,13 @@
 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");
+
+




More information about the varnish-commit mailing list