[master] 779406a Shuffle more stuff between proto-specific and generic fetch code.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Nov 27 00:26:04 CET 2013
commit 779406a61d90ad988ac3b85c9a408e5c1042355d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Nov 26 23:25:21 2013 +0000
Shuffle more stuff between proto-specific and generic fetch code.
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 576fffc..8a738cc 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -443,7 +443,31 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
assert(bo->state == BOS_REQ_DONE);
VBO_setstate(bo, BOS_FETCHING);
- V1F_fetch_body(bo);
+ switch (bo->htc.body_status) {
+ case BS_NONE:
+ break;
+ case BS_ERROR:
+ /* XXX: Why not earlier ? */
+ bo->should_close |=
+ VFP_Error(bo, "error incompatible Transfer-Encoding");
+ break;
+ default:
+ if (bo->vbc == NULL)
+ (void)VFP_Error(bo, "Backend connection gone");
+ else
+ V1F_fetch_body(bo);
+ break;
+ }
+
+ bo->t_body = VTIM_mono();
+
+ if (bo->vbc != NULL) {
+ if (bo->should_close)
+ VDI_CloseFd(&bo->vbc);
+ else
+ VDI_RecycleFd(&bo->vbc);
+ AZ(bo->vbc);
+ }
bo->vfp = NULL;
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index f236053..3e16bcb 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -330,6 +330,7 @@ V1F_fetch_body(struct busyobj *bo)
obj = bo->fetch_obj;
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
+ AN(bo->vbc);
assert(bo->state == BOS_FETCHING);
@@ -340,8 +341,6 @@ V1F_fetch_body(struct busyobj *bo)
/* XXX: pick up estimate from objdr ? */
cl = 0;
switch (htc->body_status) {
- case BS_NONE:
- break;
case BS_LENGTH:
cl = vbf_fetch_number(bo->h_content_length, 10);
@@ -366,14 +365,9 @@ V1F_fetch_body(struct busyobj *bo)
if (bo->vfp->end(bo))
assert(bo->state == BOS_FAILED);
break;
- case BS_ERROR:
- bo->should_close |=
- VFP_Error(bo, "error incompatible Transfer-Encoding");
- break;
default:
- INCOMPL();
+ WRONG("Wrong body_status");
}
- bo->t_body = VTIM_mono();
AZ(bo->vgz_rx);
/*
@@ -391,12 +385,4 @@ V1F_fetch_body(struct busyobj *bo)
STV_trim(st, st->len, 1);
}
}
-
- if (bo->vbc != NULL) {
- if (bo->should_close)
- VDI_CloseFd(&bo->vbc);
- else
- VDI_RecycleFd(&bo->vbc);
- }
- AZ(bo->vbc);
}
More information about the varnish-commit
mailing list