]> err.no Git - varnish/commitdiff
Add an undocumented debug facility that allows us to force a received
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 26 Jun 2008 21:07:07 +0000 (21:07 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 26 Jun 2008 21:07:07 +0000 (21:07 +0000)
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.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2836 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_main.c

index 5b2b3a6e55493958506ea0b7bfaf80da582759da..ebffdc03545e137326eb5bb37332e51156996401 100644 (file)
@@ -454,6 +454,7 @@ int EXP_NukeOne(struct sess *sp);
 /* 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);
index 40c61d7c62d7c21b82f2909ab85a46a405ebbd37..05fdee257fbafe68ac0089d05866999f75979015 100644 (file)
 #include "shmlog.h"
 #include "cache.h"
 #include "stevedore.h"
+#include "cli.h"
+#include "cli_priv.h"
+
+static unsigned fetchfrag;
 
 /*--------------------------------------------------------------------*/
 
@@ -199,6 +203,16 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
 
 /*--------------------------------------------------------------------*/
 
+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 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
        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 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
                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 @@ Fetch(struct sess *sp)
 
        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);
+}
+
+
index e0fa3dd37e6df21db4c2ebd325f767655e32335d..533ae20f20ca1905e8e3a0ddadc6924ed565d629 100644 (file)
@@ -72,6 +72,7 @@ child_main(void)
        THR_Name("cache-main");
 
        CLI_Init();
+       Fetch_Init();
 
        CNT_Init();
        VCL_Init();