r2836 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jun 26 23:07:07 CEST 2008


Author: phk
Date: 2008-06-26 23:07:07 +0200 (Thu, 26 Jun 2008)
New Revision: 2836

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_main.c
Log:
Add an undocumented debug facility that allows us to force a received
object to be fragmented into smaller bits are out command.

This is necessary to be able to write sensible testcases for the
abilities of the ESI parsing code to navigate storage boundaries.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2008-06-26 12:41:51 UTC (rev 2835)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2008-06-26 21:07:07 UTC (rev 2836)
@@ -454,6 +454,7 @@
 /* cache_fetch.c */
 int Fetch(struct sess *sp);
 int FetchReqBody(struct sess *sp);
+void Fetch_Init(void);
 
 /* cache_hash.c */
 void HSH_Prealloc(struct sess *sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-06-26 12:41:51 UTC (rev 2835)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-06-26 21:07:07 UTC (rev 2836)
@@ -40,7 +40,11 @@
 #include "shmlog.h"
 #include "cache.h"
 #include "stevedore.h"
+#include "cli.h"
+#include "cli_priv.h"
 
+static unsigned fetchfrag;
+
 /*--------------------------------------------------------------------*/
 
 static int
@@ -199,6 +203,16 @@
 
 /*--------------------------------------------------------------------*/
 
+static void
+dump_st(struct sess *sp, struct storage *st)
+{
+	txt t;
+
+	t.b = (void*)st->ptr;
+	t.e = (void*)(st->ptr + st->len);
+	WSLR(sp->wrk, SLT_Debug, sp->fd, t);
+}
+
 static int
 fetch_eof(struct sess *sp, struct http_conn *htc)
 {
@@ -212,10 +226,14 @@
 	st = NULL;
 	while (1) {
 		if (v == 0) {
+			if (st != NULL && fetchfrag > 0)
+				dump_st(sp, st);
 			st = STV_alloc(sp, params->fetch_chunksize * 1024);
 			VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
 			p = st->ptr + st->len;
 			v = st->space - st->len;
+			if (v > fetchfrag)
+				v = fetchfrag;
 		}
 		AN(p);
 		AN(st);
@@ -229,6 +247,8 @@
 		st->len += i;
 		sp->obj->len += i;
 	}
+	if (st != NULL && fetchfrag > 0)
+		dump_st(sp, st);
 
 	if (st->len == 0) {
 		VTAILQ_REMOVE(&sp->obj->store, st, list);
@@ -442,3 +462,34 @@
 
 	return (0);
 }
+
+/*--------------------------------------------------------------------
+ * Debugging aids
+ */
+
+static void
+debug_fragfetch(struct cli *cli, const char * const *av, void *priv)
+{
+        (void)priv;
+        (void)cli;
+	fetchfrag = strtoul(av[2], NULL, 0);
+}
+
+static struct cli_proto debug_cmds[] = {
+	{ "debug.fragfetch", "debug.fragfetch",
+		"\tEnable fetch fragmentation\n", 1, 1, debug_fragfetch },
+	{ NULL }
+};
+
+/*--------------------------------------------------------------------
+ *
+ */
+
+void
+Fetch_Init(void)
+{
+
+	CLI_AddFuncs(DEBUG_CLI, debug_cmds);
+}
+
+

Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c	2008-06-26 12:41:51 UTC (rev 2835)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c	2008-06-26 21:07:07 UTC (rev 2836)
@@ -72,6 +72,7 @@
 	THR_Name("cache-main");
 
 	CLI_Init();
+	Fetch_Init();
 
 	CNT_Init();
 	VCL_Init();




More information about the varnish-commit mailing list