[Varnish] #310: WS_Reserve panic + error

Varnish varnish-bugs at projects.linpro.no
Wed Sep 3 06:45:32 CEST 2008


#310: WS_Reserve panic + error
--------------------+-------------------------------------------------------
 Reporter:  sky     |        Owner:  des  
     Type:  defect  |       Status:  new  
 Priority:  normal  |    Milestone:       
Component:  build   |      Version:  trunk
 Severity:  normal  |   Resolution:       
 Keywords:          |  
--------------------+-------------------------------------------------------
Comment (by sky):

 {{{
 backend default {
         .host = "127.0.0.1";
         .port = "80";
 }

 backend wikia {
         .host = "xxxx";
         .port = "80";
 }

 backend armchair {
         .host = "xxxx";
         .port = "80";
 }

 backend gamewikis {
         .host = "xxxx";
         .port = "80";
 }

 backend images {
         .host = "xxxx";
         .port = "80";
 }

 # Below is a commented-out copy of the default VCL logic.  If you
 # redefine any of these subroutines, the built-in logic will be
 # appended to your code.

 ## Called when a client request is received
 #
 sub vcl_recv {


         if (req.http.Accept-Encoding) {
                 if (req.http.Accept-Encoding ~ "gzip") {
                     set req.http.Accept-Encoding = "gzip";
                 } elsif (req.http.Accept-Encoding ~ "deflate") {
                     set req.http.Accept-Encoding = "deflate";
                 } else {
                     # unkown algorithm
                     remove req.http.Accept-Encoding;
                 }
         }

         # clean out requests sent via curls -X mode and LWP
         if (req.url ~ "http://") {
                 set req.url = regsub(req.url, "http://[^/]*","");
         }


         if (req.request == "PURGE") {
           if (req.http.purgeurl) {
             purge_hash(req.http.purgeurl);
             error 200 "purged";
           } else {
             error 503 "empty purgeurl";
           }
         }

         if (req.url == "/lvscheck.html") {
                 error 200 "varnish is okay";
         }

         if(req.http.host ~ "^(nwn|oblivion|meta|war|gw)$") {
                 set req.backend = wikia;
         } elsif(req.http.host ~ "(gw.wikia.com|gamewikis.org)$") {
                 set req.backend = gamewikis;
         } elsif(req.http.host ~ "^siwiki.sportsillustrated.cnn.com$") {
                 set req.backend = armchair;
         } elsif(req.http.host ~ "^thirdturn.armchairgm.com$") {
                 set req.backend = wikia;
         } elsif(req.http.host ~ "armchairgm.com$") {
                 set req.backend = armchair;
         } elsif(req.http.host ~ "images.wikia.com") {
                 set req.backend = images;
         } else {
                 set req.backend = wikia;
         }

         if (req.url ~ "/__utm.gif") {
                 set req.url = "/__utm.gif";
         }

         if (req.url ~ "/rx") {
               error 200 "not serving this";
         }


         if (req.http.host == "216.151.156.11") {
                 set req.http.origurl = req.url;
         }


         if (req.request != "GET" && req.request != "HEAD" && req.request
 != "PURGE") {
                 pipe;
         }
         if (req.http.Expect) {
                 pipe;
         }

         if (req.http.User-Agent ~ "Opera") {
                 pipe;
         }

         if (req.http.Cookie ~ "UserID") {
                 set req.http.tmp_userid  = regsuball(req.http.Cookie,
 "(.*?)(^|;|\s)(.*UserID=[^;]*).*", "\3; ");
         } else {
                 set req.http.tmp_userid = " ";
         }
         if (req.http.Cookie ~ "UserName") {
                 set req.http.tmp_username  = regsuball(req.http.Cookie,
 "(.*?)(^|;|\s)(.*UserName=[^;]*).*", "\3; ");
         } else {
                 set req.http.tmp_username = " ";
         }
         if (req.http.Cookie ~ "session") {
                 set req.http.tmp_session  = regsub(req.http.Cookie,
 "(.*)(^|;|\s)(.*session=[^;]*).*", "\3; ");
         } else {
                 set req.http.tmp_session = " ";
         }
         if (req.http.Cookie ~ "Token") {
                 set req.http.tmp_token  = regsub(req.http.Cookie,
 "(.*)(^|;|\s)(.*Token=[^;]*).*", "\3; ");
         } else {
                 set req.http.tmp_token = " ";
         }
         if (req.http.Cookie ~ "LoggedOut") {
                 set req.http.tmp_loggedout  = regsub(req.http.Cookie,
 "(.*)(^|;|\s)(.*LoggedOut=[^;]*).*", "\3; ");
         } else {
                 set req.http.tmp_loggedout = " ";
         }
         set req.http.Cookie = "";
         set req.http.Cookie = req.http.tmp_userid " ; "
 req.http.tmp_session " ; " req.http.tmp_token " ; " req.http.tmp_username
 " ; " req.http.tmp_loggedout;
         remove req.http.tmp_userid;
         remove req.http.tmp_session;
         remove req.http.tmp_token;
         remove req.http.tmp_loggedout;
         remove req.http.tmp_username;

         if (req.http.Authenticate) {
                 pass;
         }
         lookup;
 }


 sub vcl_hash {
         set req.hash += req.url;
         set req.hash += req.http.host;
         hash;
 }

 #
 ## Called when entering pipe mode
 #
 #sub vcl_pipe {
 #       pipe;
 #}
 #
 ## Called when entering pass mode
 #
 #sub vcl_pass {
 #        set resp.http.foo = "x";
 #       pass;
 #}
 #
 ## Called when entering an object into the cache
 #


 #
 ## Called when the requested object was found in the cache
 #
 sub vcl_hit {
        if (req.request == "PURGE") {
                 error 200 "purged";
         }

         if (!obj.cacheable) {
                 pass;
         }
         if (obj.http.X-Cache == "MISS") {
                 set obj.http.X-Cache = "HIT";
         }

         deliver;
 }
 #
 ## Called when the requested object was not found in the cache
 #
 sub vcl_miss {
        if (req.request == "PURGE") {
 #               nuke;
                 error 200 "purged";
         }

         fetch;
 }
 #
 ## Called when the requested object has been retrieved from the
 ## backend, or the request to the backend has failed
 #
 sub vcl_fetch {
         set obj.http.X-Cache = "MISS";
         # this is the old wow ip, so issue redirect
         if (req.http.host == "216.151.156.11") {
                 set obj.http.origurl = req.http.origurl;
         }

         if (!obj.cacheable) {
                 set obj.http.X-Cacheable = "NO:Not-Cacheable";
                 pass;
         }
         if (obj.http.Cache-Control ~ "private") {
                 if(req.http.Cookie ~"(UserID|_session)") {
                         set obj.http.X-Cacheable = "NO:Got Session";
                 } else {
                         set obj.http.X-Cacheable = "NO:Cache-
 Control=private";
                 }
                 pass;
         }
         if (obj.http.Set-Cookie ~ "(UserID|_session)") {
                 set obj.http.X-Cacheable = "NO:Set-Cookie";
                 pass;
         }

         set obj.http.X-Cacheable = "YES";
         set obj.grace = 10s;
         deliver;
 }

 sub vcl_prefetch {
         pass;
 }

 #
 #
 ## Called before a cached object is delivered to the client
 #
 sub vcl_deliver {

         set resp.http.X-Served-By = "varnish2";

         # this is the old wow ip, so issue redirect
         if (resp.http.origurl) {
                 set resp.http.Location = regsub(resp.http.origurl, "^" ,
 "http://www.wowwiki.com");
                 set resp.status = 301;
                 set resp.response = "Moved Permanently";
                 deliver;
         }



     set resp.http.Cache-Control = "private, s-maxage=0, max-age=0, must-
 revalidate";
     set resp.http.Expires = "Thu, 01 Jan 1970 00:00:00 GMT";
     if(!resp.http.Vary) {
         set resp.http.Vary = "Accept-Encoding,Cookie";
         }
     deliver;
 }
 }}}

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/310#comment:2>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list