r5714 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Tue Jan 11 13:00:43 CET 2011


Author: phk
Date: 2011-01-11 13:00:42 +0100 (Tue, 11 Jan 2011)
New Revision: 5714

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_gzip.c
Log:
Un-const the sp argument to vpf methods



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2011-01-11 11:24:39 UTC (rev 5713)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2011-01-11 12:00:42 UTC (rev 5714)
@@ -213,9 +213,9 @@
 
 /* Fetch processors --------------------------------------------------*/
 
-typedef void vfp_begin_f(const struct sess *, size_t );
-typedef int vfp_bytes_f(const struct sess *, struct http_conn *, size_t);
-typedef int vfp_end_f(const struct sess *sp);
+typedef void vfp_begin_f(struct sess *, size_t );
+typedef int vfp_bytes_f(struct sess *, struct http_conn *, size_t);
+typedef int vfp_end_f(struct sess *sp);
 
 struct vfp {
 	vfp_begin_f	*begin;
@@ -279,6 +279,7 @@
 	enum body_status	body_status;
 	struct storage		*storage;
 	struct vfp		*vfp;
+	void			*vfp_private;
 	unsigned		do_esi;
 	unsigned		do_gzip;
 	unsigned		do_gunzip;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2011-01-11 11:24:39 UTC (rev 5713)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2011-01-11 12:00:42 UTC (rev 5714)
@@ -598,8 +598,7 @@
 	l += strlen("Content-Encoding: XxxXxxXxxXxxXxxXxx" + sizeof(void *));
 
 	/*
-	 * XXX: If we have a Length: header, we should allocate the body
-	 * XXX: also.
+	 * XXX: VFP's may affect estimate
 	 */
 
 	sp->obj = STV_NewObject(sp, sp->wrk->storage_hint, l,
@@ -644,6 +643,11 @@
 		sp->obj->last_modified = sp->wrk->entered;
 
 	AZ(sp->wrk->vfp);
+	/* XXX: precedence, also: do_esi */
+	if (sp->wrk->do_gunzip)
+		sp->wrk->vfp = &vfp_gunzip;
+	else if (sp->wrk->do_gzip)
+		sp->wrk->vfp = &vfp_gzip;
 	i = FetchBody(sp);
 	sp->wrk->vfp = NULL;
 	AZ(sp->wrk->wfd);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2011-01-11 11:24:39 UTC (rev 5713)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2011-01-11 12:00:42 UTC (rev 5714)
@@ -61,7 +61,7 @@
  * as seen on the socket, or zero if unknown.
  */
 static void
-vfp_nop_begin(const struct sess *sp, size_t estimate)
+vfp_nop_begin(struct sess *sp, size_t estimate)
 {
 
 	AZ(sp->wrk->storage);
@@ -85,7 +85,7 @@
  */
 
 static int
-vfp_nop_bytes(const struct sess *sp, struct http_conn *htc, size_t bytes)
+vfp_nop_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
 {
 	ssize_t l, w;
 	struct storage *st;
@@ -131,7 +131,7 @@
  */
 
 static int
-vfp_nop_end(const struct sess *sp)
+vfp_nop_end(struct sess *sp)
 {
 	struct storage *st;
 
@@ -182,7 +182,7 @@
 /*--------------------------------------------------------------------*/
 
 static int
-fetch_straight(const struct sess *sp, struct http_conn *htc, const char *b)
+fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
 {
 	int i;
 	ssize_t cl;
@@ -220,7 +220,7 @@
 	} while (0)
 
 static int
-fetch_chunked(const struct sess *sp, struct http_conn *htc)
+fetch_chunked(struct sess *sp, struct http_conn *htc)
 {
 	int i;
 	char buf[20];		/* XXX: 20 is arbitrary */
@@ -290,7 +290,7 @@
 /*--------------------------------------------------------------------*/
 
 static int
-fetch_eof(const struct sess *sp, struct http_conn *htc)
+fetch_eof(struct sess *sp, struct http_conn *htc)
 {
 	int i;
 

Modified: trunk/varnish-cache/bin/varnishd/cache_gzip.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_gzip.c	2011-01-11 11:24:39 UTC (rev 5713)
+++ trunk/varnish-cache/bin/varnishd/cache_gzip.c	2011-01-11 12:00:42 UTC (rev 5714)
@@ -127,7 +127,7 @@
 }
 
 /*--------------------------------------------------------------------*/
-#include <stdio.h>
+
 int
 VGZ_Produce(struct vgz *vg, const void **pptr, size_t *plen)
 {
@@ -151,7 +151,6 @@
 		return (1);
 	if (i == Z_BUF_ERROR)
 		return (2);
-fprintf(stderr, "--------------------> GUNZIP = %d\n", i);
 	return (-1);
 }
 
@@ -175,25 +174,29 @@
  */
 
 static void
-vfp_gunzip_begin(const struct sess *sp, size_t estimate)
+vfp_gunzip_begin(struct sess *sp, size_t estimate)
 {
-	(void)sp;
 	(void)estimate;
+	sp->wrk->vfp_private = VGZ_NewUnzip(sp, sp->ws, sp->wrk->ws);
 }
 
 static int
-vfp_gunzip_bytes(const struct sess *sp, struct http_conn *htc, size_t bytes)
+vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
 {
-	(void)sp;
+	struct vgz *vgz;
+
+	CAST_OBJ_NOTNULL(vgz, sp->wrk->vfp_private, VGZ_MAGIC);
 	(void)htc;
 	(void)bytes;
 	return (-1);
 }
 
 static int
-vfp_gunzip_end(const struct sess *sp)
+vfp_gunzip_end(struct sess *sp)
 {
-	(void)sp;
+	struct vgz *vgz;
+
+	CAST_OBJ_NOTNULL(vgz, sp->wrk->vfp_private, VGZ_MAGIC);
 	return (-1);
 }
 
@@ -211,14 +214,14 @@
  */
 
 static void
-vfp_gzip_begin(const struct sess *sp, size_t estimate)
+vfp_gzip_begin(struct sess *sp, size_t estimate)
 {
 	(void)sp;
 	(void)estimate;
 }
 
 static int
-vfp_gzip_bytes(const struct sess *sp, struct http_conn *htc, size_t bytes)
+vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
 {
 	(void)sp;
 	(void)htc;
@@ -227,7 +230,7 @@
 }
 
 static int
-vfp_gzip_end(const struct sess *sp)
+vfp_gzip_end(struct sess *sp)
 {
 	(void)sp;
 	return (-1);




More information about the varnish-commit mailing list