r3834 - in trunk/varnish-cache: bin/varnishd bin/varnishtest include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Fri Feb 27 13:02:50 CET 2009
Author: phk
Date: 2009-02-27 13:02:50 +0100 (Fri, 27 Feb 2009)
New Revision: 3834
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishtest/vtc_http.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Add a beresp.* variable family, which contains the backend response
before filtering.
Cut Fetch() into two, FetchHdr() and FetchBody(), for now, just call
them sequentially from cache_center.c
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2009-02-27 12:02:50 UTC (rev 3834)
@@ -477,7 +477,8 @@
int EXP_NukeOne(struct sess *sp);
/* cache_fetch.c */
-int Fetch(struct sess *sp);
+int FetchHdr(struct sess *sp);
+int FetchBody(struct sess *sp);
int FetchReqBody(struct sess *sp);
void Fetch_Init(void);
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -355,7 +355,7 @@
DOT ]
DOT vcl_fetch [
DOT shape=record
-DOT label="vcl_fetch()|req.\nobj.\nbereq."
+DOT label="vcl_fetch()|req.\nobj.\nbereq.\nberesp."
DOT ]
DOT fetch -> vcl_fetch [style=bold,color=blue,weight=2]
DOT fetch_pass [
@@ -385,7 +385,9 @@
AN(sp->bereq);
AN(sp->director);
AZ(sp->vbe);
- i = Fetch(sp);
+ i = FetchHdr(sp);
+ if (i == 0)
+ i = FetchBody(sp);
AZ(sp->wrk->wfd);
AZ(sp->vbe);
AN(sp->director);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -308,16 +308,13 @@
/*--------------------------------------------------------------------*/
int
-Fetch(struct sess *sp)
+FetchHdr(struct sess *sp)
{
struct vbe_conn *vc;
struct worker *w;
char *b;
- int cls;
- struct http *hp, *hp2;
- struct storage *st;
+ struct http *hp;
struct bereq *bereq;
- int mklen, is_head;
struct http_conn htc[1];
int i;
@@ -335,7 +332,6 @@
w = sp->wrk;
bereq = sp->bereq;
hp = &bereq->http[0];
- is_head = (strcasecmp(http_GetReq(hp), "head") == 0);
sp->obj->xid = sp->xid;
@@ -398,7 +394,37 @@
return (__LINE__);
}
+ return (0);
+
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+FetchBody(struct sess *sp)
+{
+ struct vbe_conn *vc;
+ char *b;
+ int cls;
+ struct http *hp, *hp2;
+ struct storage *st;
+ int mklen, is_head;
+ struct http_conn htc[1];
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC);
+ hp = &sp->bereq->http[1];
+ AN(sp->director);
+ if (sp->obj->objcore != NULL) /* pass has no objcore */
+ AN(ObjIsBusy(sp->obj));
+ AN(sp->bereq);
+
+ vc = sp->vbe;
+
sp->obj->entered = TIM_real();
+ is_head = (strcasecmp(http_GetReq(&sp->bereq->http[0]), "head") == 0);
if (http_GetHdr(hp, H_Last_Modified, &b))
sp->obj->last_modified = TIM_parse(b);
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -102,6 +102,9 @@
case HDR_BEREQ:
hp = &sp->bereq->http[0];
break;
+ case HDR_BERESP:
+ hp = &sp->bereq->http[1];
+ break;
case HDR_RESP:
hp = sp->http;
break;
Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -321,6 +321,11 @@
pfd[0].events = POLLIN;
pfd[0].revents = 0;
i = poll(pfd, 1, hp->timeout);
+ if (i <= 0) {
+ vtc_log(hp->vl, 0, "HTTP rx failed (%s)",
+ strerror(errno));
+ exit (1);
+ }
assert(i > 0);
assert(hp->prxbuf < hp->nrxbuf);
i = read(hp->fd, hp->rxbuf + hp->prxbuf, n);
@@ -341,8 +346,7 @@
i = http_rxchar_eof(hp, n);
if (i <= 0) {
- vtc_log(hp->vl, 0, "HTTP rx failed (%s)",
- strerror(errno));
+ vtc_log(hp->vl, 0, "HTTP rx failed (%s)", strerror(errno));
exit (1);
}
assert(i > 0);
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/include/vrt.h 2009-02-27 12:02:50 UTC (rev 3834)
@@ -150,7 +150,7 @@
void VRT_error(struct sess *, unsigned, const char *);
int VRT_switch_config(const char *);
-enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };
+enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *,
const char *, ...);
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/include/vrt_obj.h 2009-02-27 12:02:50 UTC (rev 3834)
@@ -34,6 +34,12 @@
void VRT_l_bereq_first_byte_timeout(struct sess *, double);
double VRT_r_bereq_between_bytes_timeout(struct sess *);
void VRT_l_bereq_between_bytes_timeout(struct sess *, double);
+const char * VRT_r_beresp_request(const struct sess *);
+void VRT_l_beresp_request(const struct sess *, const char *, ...);
+const char * VRT_r_beresp_url(const struct sess *);
+void VRT_l_beresp_url(const struct sess *, const char *, ...);
+const char * VRT_r_beresp_proto(const struct sess *);
+void VRT_l_beresp_proto(const struct sess *, const char *, ...);
const char * VRT_r_obj_proto(const struct sess *);
void VRT_l_obj_proto(const struct sess *, const char *, ...);
int VRT_r_obj_status(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -159,8 +159,8 @@
/* ../../include/vcl.h */
- vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3534 2009-01-19 13");
- vsb_cat(sb, ":46:31Z phk $\n *\n * NB: This file is machine genera");
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3781 2009-02-17 10");
+ vsb_cat(sb, ":29:20Z phk $\n *\n * NB: This file is machine genera");
vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n");
vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");
@@ -293,15 +293,15 @@
vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);");
vsb_cat(sb, "\nint VRT_switch_config(const char *);\n");
vsb_cat(sb, "\nenum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BERE");
- vsb_cat(sb, "Q };\nchar *VRT_GetHdr(const struct sess *, enum gethd");
- vsb_cat(sb, "r_e where, const char *);\nvoid VRT_SetHdr(const struc");
- vsb_cat(sb, "t sess *, enum gethdr_e where, const char *,\n");
- vsb_cat(sb, " const char *, ...);\nvoid VRT_handling(struct sess");
- vsb_cat(sb, " *sp, unsigned hand);\n\n/* Simple stuff */\n");
- vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n");
- vsb_cat(sb, "void VRT_memmove(void *dst, const void *src, unsigned ");
- vsb_cat(sb, "len);\n\nvoid VRT_ESI(struct sess *sp);\n");
- vsb_cat(sb, "void VRT_Rollback(struct sess *sp);\n");
+ vsb_cat(sb, "Q, HDR_BERESP };\nchar *VRT_GetHdr(const struct sess *");
+ vsb_cat(sb, ", enum gethdr_e where, const char *);\n");
+ vsb_cat(sb, "void VRT_SetHdr(const struct sess *, enum gethdr_e whe");
+ vsb_cat(sb, "re, const char *,\n const char *, ...);\n");
+ vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n");
+ vsb_cat(sb, "\n/* Simple stuff */\nint VRT_strcmp(const char *s1, c");
+ vsb_cat(sb, "onst char *s2);\nvoid VRT_memmove(void *dst, const voi");
+ vsb_cat(sb, "d *src, unsigned len);\n\nvoid VRT_ESI(struct sess *sp");
+ vsb_cat(sb, ");\nvoid VRT_Rollback(struct sess *sp);\n");
vsb_cat(sb, "\n/* Synthetic pages */\nvoid VRT_synth_page(struct se");
vsb_cat(sb, "ss *sp, unsigned flags, const char *, ...);\n");
vsb_cat(sb, "\n/* Backend related */\nvoid VRT_init_dir_simple(stru");
@@ -322,9 +322,9 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3406 2008-11-19 14:13:57Z ");
- vsb_cat(sb, "petter $\n *\n * NB: This file is machine generated, ");
- vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3781 2009-02-17 10:29:20Z ");
+ vsb_cat(sb, "phk $\n *\n * NB: This file is machine generated, DO ");
+ vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
vsb_cat(sb, "s *);\nint VRT_r_server_port(struct sess *);\n");
@@ -354,19 +354,25 @@
vsb_cat(sb, "*);\nvoid VRT_l_bereq_first_byte_timeout(struct sess *");
vsb_cat(sb, ", double);\ndouble VRT_r_bereq_between_bytes_timeout(s");
vsb_cat(sb, "truct sess *);\nvoid VRT_l_bereq_between_bytes_timeout");
- vsb_cat(sb, "(struct sess *, double);\nconst char * VRT_r_obj_proto");
- vsb_cat(sb, "(const struct sess *);\nvoid VRT_l_obj_proto(const str");
- vsb_cat(sb, "uct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_obj_status(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_status(const struct sess *, int);\n");
- vsb_cat(sb, "const char * VRT_r_obj_response(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_response(const struct sess *, const cha");
- vsb_cat(sb, "r *, ...);\nint VRT_r_obj_hits(const struct sess *);\n");
- vsb_cat(sb, "unsigned VRT_r_obj_cacheable(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned");
- vsb_cat(sb, ");\ndouble VRT_r_obj_ttl(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_grace(const struct sess *);\n");
+ vsb_cat(sb, "(struct sess *, double);\nconst char * VRT_r_beresp_re");
+ vsb_cat(sb, "quest(const struct sess *);\nvoid VRT_l_beresp_request");
+ vsb_cat(sb, "(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_beresp_url(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_beresp_url(const struct sess *, const char ");
+ vsb_cat(sb, "*, ...);\nconst char * VRT_r_beresp_proto(const struct");
+ vsb_cat(sb, " sess *);\nvoid VRT_l_beresp_proto(const struct sess *");
+ vsb_cat(sb, ", const char *, ...);\nconst char * VRT_r_obj_proto(co");
+ vsb_cat(sb, "nst struct sess *);\nvoid VRT_l_obj_proto(const struct");
+ vsb_cat(sb, " sess *, const char *, ...);\nint VRT_r_obj_status(con");
+ vsb_cat(sb, "st struct sess *);\nvoid VRT_l_obj_status(const struct");
+ vsb_cat(sb, " sess *, int);\nconst char * VRT_r_obj_response(const ");
+ vsb_cat(sb, "struct sess *);\nvoid VRT_l_obj_response(const struct ");
+ vsb_cat(sb, "sess *, const char *, ...);\nint VRT_r_obj_hits(const ");
+ vsb_cat(sb, "struct sess *);\nunsigned VRT_r_obj_cacheable(const st");
+ vsb_cat(sb, "ruct sess *);\nvoid VRT_l_obj_cacheable(const struct s");
+ vsb_cat(sb, "ess *, unsigned);\ndouble VRT_r_obj_ttl(const struct s");
+ vsb_cat(sb, "ess *);\nvoid VRT_l_obj_ttl(const struct sess *, doubl");
+ vsb_cat(sb, "e);\ndouble VRT_r_obj_grace(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_obj_grace(const struct sess *, double);\n");
vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
vsb_cat(sb, "const char * VRT_r_obj_hash(const struct sess *);\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2009-02-27 12:02:50 UTC (rev 3834)
@@ -106,6 +106,7 @@
"struct sess *"
}
+ #######################################################################
# Request sent to backend
{ bereq.request
RW STRING
@@ -143,6 +144,30 @@
"struct sess *"
}
+ #######################################################################
+ # Response from the backend
+ { beresp.request
+ RW STRING
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.url
+ RW STRING
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.proto
+ RW STRING
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.http.
+ RW HDR_BEREQ
+ { fetch }
+ "const struct sess *"
+ }
+
+ #######################################################################
# The (possibly) cached object
{ obj.proto
RW STRING
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-02-27 11:36:16 UTC (rev 3833)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-02-27 12:02:50 UTC (rev 3834)
@@ -123,6 +123,26 @@
V_RW, 0,
VCL_MET_PASS | VCL_MET_MISS
},
+ { "beresp.request", STRING, 14,
+ "VRT_r_beresp_request(sp)", "VRT_l_beresp_request(sp, ",
+ V_RW, 0,
+ VCL_MET_FETCH
+ },
+ { "beresp.url", STRING, 10,
+ "VRT_r_beresp_url(sp)", "VRT_l_beresp_url(sp, ",
+ V_RW, 0,
+ VCL_MET_FETCH
+ },
+ { "beresp.proto", STRING, 12,
+ "VRT_r_beresp_proto(sp)", "VRT_l_beresp_proto(sp, ",
+ V_RW, 0,
+ VCL_MET_FETCH
+ },
+ { "beresp.http.", HEADER, 12,
+ "VRT_r_beresp_http_(sp)", "VRT_l_beresp_http_(sp, ",
+ V_RW, "HDR_BEREQ",
+ VCL_MET_FETCH
+ },
{ "obj.proto", STRING, 9,
"VRT_r_obj_proto(sp)", "VRT_l_obj_proto(sp, ",
V_RW, 0,
More information about the varnish-commit
mailing list