Hi,

Some time ago Thomas Souvignet sent a patch on the varnish-dev mailing list that implements range support with streaming (for varnish 3.0S).

There were some bugs with his implementation so here are three patches that correct them.

Regards,

--
Jocelyn De La Rosa - Developer, Research&  Engineering
SmartJog | www.smartjog.com
27 Blvd Hippolyte Marquès, 94200 Ivry-sur-Seine, France

>From 137a1c351b7fb2efec22b83be5319ae5bab931b3 Mon Sep 17 00:00:00 2001
From: Jocelyn De La Rosa <[email protected]>
Date: Mon, 6 Feb 2012 15:58:25 +0100
Subject: [PATCH 1/3] Fix http_range_support flag off with streaming mode

---
 bin/varnishd/cache_response.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 3134e3b..41c73ab 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -459,7 +459,7 @@ RES_StreamWrite(const struct sess *sp)
         low = 0;
         high = 0;
         /* check if range header is present */
-        if (http_GetHdr(sp->http, H_Range, &r))
+        if (params->http_range_support && http_GetHdr(sp->http, H_Range, &r))
 		res_dorange(sp, r, &low, &high);
 
         if (high != 0) {
-- 
1.7.2.5

>From 38eb9aaed6b0332258060fa0b61fabe8fa9c6051 Mon Sep 17 00:00:00 2001
From: Jocelyn De La Rosa <[email protected]>
Date: Mon, 6 Feb 2012 16:01:02 +0100
Subject: [PATCH 2/3] Fix concecutive range requests whith streaming mode

---
 bin/varnishd/cache_response.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 41c73ab..61746d6 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -521,8 +521,10 @@ RES_StreamWrite(const struct sess *sp)
 			break;
 
                 /* Check if we sent enough data, if so get out of here */
-                if (high && sctx->stream_next == high)
-                        break;
+                if (high && sctx->stream_next == high) {
+			sctx->stream_started = 2;
+			break;
+                }
 
 		assert(sctx->stream_next < sctx->stream_max);
 		AN(VTAILQ_NEXT(st, list));
@@ -626,7 +628,10 @@ RES_StreamBody(struct sess *sp)
 		sctx.stream_max = bo->stream_max;
 		assert(sctx.stream_max >= sctx.stream_next);
 		Lck_Unlock(&bo->mtx);
-		RES_StreamWrite(sp);
+		if (sctx.stream_started != 2)
+			RES_StreamWrite(sp);
+		else
+			sctx.stream_next = bo->stream_max;
 		Lck_Lock(&bo->mtx);
 		if (fast_writer) {
 			bo->stream_tokens++;
-- 
1.7.2.5

>From c3d616a2309505ef3ff41bfb037e575828b9f863 Mon Sep 17 00:00:00 2001
From: Jocelyn De La Rosa <[email protected]>
Date: Mon, 6 Feb 2012 16:06:31 +0100
Subject: [PATCH 3/3] Add object response check to range support

---
 bin/varnishd/cache_response.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 61746d6..4c5f207 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -459,7 +459,8 @@ RES_StreamWrite(const struct sess *sp)
         low = 0;
         high = 0;
         /* check if range header is present */
-        if (params->http_range_support && http_GetHdr(sp->http, H_Range, &r))
+        if (params->http_range_support && http_GetHdr(sp->http, H_Range, &r) &&
+	    sp->obj->response == 200)
 		res_dorange(sp, r, &low, &high);
 
         if (high != 0) {
-- 
1.7.2.5

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to