Commit 6eaba03f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2836 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent b84e80ef
......@@ -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);
......
......@@ -40,6 +40,10 @@
#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);
}
......@@ -72,6 +72,7 @@ child_main(void)
THR_Name("cache-main");
CLI_Init();
Fetch_Init();
CNT_Init();
VCL_Init();
......
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