]> err.no Git - varnish/commitdiff
Implement "error" action in vcl_fetch() and vcl_deliver()
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 7 Aug 2007 07:23:10 +0000 (07:23 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 7 Aug 2007 07:23:10 +0000 (07:23 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1808 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_center.c

index e7cc5341c656f2b763f7bd620dc015f4328767cf..6d1f4e9eee118117194b51685e63a44f4b18757c 100644 (file)
@@ -149,8 +149,17 @@ cnt_deliver(struct sess *sp)
        sp->t_resp = TIM_real();
        RES_BuildHttp(sp);
        VCL_deliver_method(sp);
-       if (sp->handling != VCL_RET_DELIVER) 
+       switch (sp->handling) {
+       case VCL_RET_DELIVER:
+               break;
+       case VCL_RET_ERROR:
+               HSH_Deref(sp->obj);
+               sp->obj = NULL;
+               sp->step = STP_ERROR;
+               return (0);
+       default:
                INCOMPL();
+       }
 
        RES_WriteObj(sp);
        HSH_Deref(sp->obj);
@@ -323,11 +332,23 @@ cnt_fetch(struct sess *sp)
 
                VCL_fetch_method(sp);
 
-               if (sp->handling == VCL_RET_ERROR)
-                       INCOMPL();
-
-               if (sp->handling == VCL_RET_PASS)
+               switch (sp->handling) {
+               case VCL_RET_ERROR:
+                       sp->obj->ttl = 0;
+                       sp->obj->cacheable = 0;
+                       HSH_Unbusy(sp->obj);
+                       HSH_Deref(sp->obj);
+                       sp->obj = NULL;
+                       sp->step = STP_ERROR;
+                       return (0);
+               case VCL_RET_PASS:
                        sp->obj->pass = 1;
+                       break;
+               case VCL_RET_INSERT:
+                       break;
+               default:
+                       INCOMPL();
+               }
        }
 
        sp->obj->cacheable = 1;