]> err.no Git - varnish/commitdiff
Merged revisions 1394,1400-1418 via svnmerge from
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 14 May 2007 09:42:16 +0000 (09:42 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 14 May 2007 09:42:16 +0000 (09:42 +0000)
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1394 | phk | 2007-05-09 12:55:33 +0200 (Wed, 09 May 2007) | 8 lines

  After compilation of a VCL program, do a test-load into the management
  process to catch any implementation-discrepancies between symbols used
  by the compiler and those implemented in the runtime.

  The situation will happen from time to time and there is no need to
  issue a panic when we can test sensibly for it.
........
  r1403 | ingvar | 2007-05-11 09:51:11 +0200 (Fri, 11 May 2007) | 5 lines

  * Fri May 11 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.0.svn-20070511
  - Threw latest changes into svn trunk
  - Removed the conversion of manpages into utf8. They are all utf8 in trunk
........
  r1404 | ingvar | 2007-05-11 10:13:03 +0200 (Fri, 11 May 2007) | 1 line
........
  r1406 | des | 2007-05-11 13:06:03 +0200 (Fri, 11 May 2007) | 2 lines

  Comment out comparisons which are always true (unsigned >= 0)
........
  r1407 | des | 2007-05-11 13:06:38 +0200 (Fri, 11 May 2007) | 2 lines

  Tweak DEVELOPER_CFLAGS.
........
  r1408 | des | 2007-05-11 13:14:32 +0200 (Fri, 11 May 2007) | 2 lines

  Pull flopen() and pidfile_*() (renamed to vpf_*()) from FreeBSD.
........
  r1409 | des | 2007-05-11 13:15:46 +0200 (Fri, 11 May 2007) | 2 lines

  Expand tags.
........
  r1410 | des | 2007-05-11 13:17:09 +0200 (Fri, 11 May 2007) | 2 lines

  No use expanding tags unless there *are* tags...
........
  r1411 | des | 2007-05-11 13:34:42 +0200 (Fri, 11 May 2007) | 2 lines

  Add -D (daemonize) and -P (pid file) options.
........
  r1412 | des | 2007-05-11 13:35:59 +0200 (Fri, 11 May 2007) | 2 lines

  Remove unused header.
........
  r1413 | des | 2007-05-11 14:01:47 +0200 (Fri, 11 May 2007) | 2 lines

  Avoid gcc4-specific compiler options.
........
  r1414 | des | 2007-05-11 14:05:02 +0200 (Fri, 11 May 2007) | 2 lines

  Forgotten commit: check for <vis.h> and daemon(3) availability.
........
  r1415 | des | 2007-05-11 14:17:26 +0200 (Fri, 11 May 2007) | 2 lines

  Add -P (pid file) option.
........
  r1416 | des | 2007-05-11 14:19:48 +0200 (Fri, 11 May 2007) | 2 lines

  Minor style issues.
........
  r1417 | phk | 2007-05-11 15:15:16 +0200 (Fri, 11 May 2007) | 7 lines

  Make the sendfile threshold inifinity for now, we have evidence of
  sendfile not doing it's job in a number of operating system (-versions ?)

  This change is unlikely to cause a performance hit anywhere, because
  writev() is pretty effective in the first place.
........
  r1418 | des | 2007-05-14 11:02:23 +0200 (Mon, 14 May 2007) | 2 lines

  Document the inadvisability of enabling sendfile.
........

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1419 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_backend.c
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishtop/varnishtop.c

index a26a6234906a044171c8c2532fa3aa4c13d9800d..c12fad55232e5b445d8b742544d875d126e7665a 100644 (file)
@@ -435,6 +435,7 @@ void WSL_Flush(struct worker *w);
 
 /* cache_response.c */
 void RES_Error(struct sess *sp, int code, const char *reason);
+int Fake(struct sess *sp, int status, const char *reason, int ttl);
 void RES_WriteObj(struct sess *sp);
 
 /* cache_vcl.c */
index 3570397d07f9806b2792f66a6d87145412e93ba8..ff25467537c8cdd2edf8e4ae0b6499d21e556072 100644 (file)
@@ -320,7 +320,9 @@ VBE_GetFd(struct sess *sp)
                }
                usleep(100000 * n);
        }
+#if 0
        RES_Error(sp, 503, "Backend did not respond.");
+#endif
        return (NULL);
 }
 
index 75e077018dffbe1fae7087081d64103e3e0ab2f8..5b428f4e3695e0158e96ec3973438818c257166d 100644 (file)
@@ -286,26 +286,19 @@ static int
 cnt_fetch(struct sess *sp)
 {
 
-
        if (Fetch(sp)) {
-               sp->obj->cacheable = 0;
-               HSH_Unbusy(sp->obj);
-               HSH_Deref(sp->obj);
-               sp->obj = NULL;
-               sp->step = STP_DONE;
-               RES_Error(sp, 503, NULL);
-               return (0);
-       }
+               AZ(Fake(sp, 503, "Backend did not respond.", 30));
+       } else {
+               RFC2616_cache_policy(sp, &sp->obj->http);       /* XXX -> VCL */
 
-       RFC2616_cache_policy(sp, &sp->obj->http);       /* XXX -> VCL */
+               VCL_fetch_method(sp);
 
-       VCL_fetch_method(sp);
+               if (sp->handling == VCL_RET_ERROR)
+                       INCOMPL();
 
-       if (sp->handling == VCL_RET_ERROR)
-               INCOMPL();
-
-       if (sp->handling == VCL_RET_PASS)
-               sp->obj->pass = 1;
+               if (sp->handling == VCL_RET_PASS)
+                       sp->obj->pass = 1;
+       }
 
        sp->obj->cacheable = 1;
        if (sp->obj->objhead != NULL) {
index 13b4fec96d99a625a4f9e1200abdd2d843fed096..fb3b79fbcb06e4d4c7179d39c0e0115ddad134a5 100644 (file)
  * $Id$
  */
 
-#include <stdio.h>             /* XXX: for NULL ?? */
-#include <string.h>            /* XXX: for NULL ?? */
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include <stdlib.h>
+
 #ifndef HAVE_CLOCK_GETTIME
 #include "compat/clock_gettime.h"
 #endif
@@ -134,7 +134,7 @@ RES_Error(struct sess *sp, int code, const char *reason)
        vsb_cat(sb,
                "Server: Varnish\r\n"
                "Connection: close\r\n"
-               "Content-Type: text/html; charset=iso-8859-1\r\n"
+               "Content-Type: text/html; charset=utf-8\r\n"
                "\r\n"
                "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
                "<HTML>\r\n"
@@ -162,6 +162,117 @@ RES_Error(struct sess *sp, int code, const char *reason)
        vsb_delete(sb);
 }
 
+/*--------------------------------------------------------------------*/
+
+int
+Fake(struct sess *sp, int status, const char *reason, int ttl)
+{
+       struct storage *st;
+       struct object *o;
+       struct vsb vsb;
+       struct http_msg *mp;
+       const char *msg;
+       char buf[40];
+       time_t now;
+       size_t len;
+
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+       CHECK_OBJ_NOTNULL(&sp->obj->http, HTTP_MAGIC);
+       assert(sp->obj->busy != 0);
+       o = sp->obj;
+       time(&now);
+
+       assert(status >= 100 && status <= 999);
+       msg = "Unknown error";
+       for (mp = http_msg; mp->nbr != 0 && mp->nbr <= status; mp++)  {
+               if (mp->nbr < status)
+                       continue;
+               if (mp->nbr > status)
+                       break;
+               msg = mp->txt;
+               if (reason == NULL)
+                       reason = mp->reason;
+               break;
+       }
+       if (reason == NULL)
+               reason = msg;
+       AN(reason);
+       AN(msg);
+
+       o->response = status;
+       o->valid = 1;
+       o->entered = now;
+       o->ttl = now + ttl;
+       o->last_modified = now;
+
+       /* generate body */
+       st = stevedore->alloc(stevedore, 1024);
+       XXXAN(st->stevedore);
+       TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+
+       vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN);
+       vsb_cat(&vsb,
+           "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
+           "<HTML>\r\n"
+           "  <HEAD>\r\n");
+       vsb_printf(&vsb,
+           "    <TITLE>%03d %s</TITLE>\r\n", status, msg);
+       vsb_printf(&vsb,
+           "  </HEAD>\r\n"
+           "  <BODY>\r\n");
+       vsb_printf(&vsb,
+           "    <H1>Error %03d %s</H1>\r\n", status, msg);
+       vsb_printf(&vsb,
+           "    <P>%s</P>\r\n", reason);
+       vsb_printf(&vsb,
+           "    <H3>Guru Meditation:</H3>\r\n");
+       vsb_printf(&vsb,
+           "    <P>XID: %u</P>\r\n", sp->xid);
+       vsb_printf(&vsb,
+           "    <I><A href=\"http://www.varnish-cache.org/\">Varnish</A></I>\r\n"
+           "  </BODY>\r\n"
+           "</HTML>\r\n");
+       vsb_finish(&vsb);
+       vsb_finish(&vsb);
+       o->len = st->len = vsb_len(&vsb);
+       vsb_delete(&vsb);
+
+       /* generate header */
+       o->http.s = calloc(len = 1024, 1);
+       XXXAN(o->http.s);
+       o->http.e = o->http.s + len;
+
+       /* XXX we could use a little less magic here */
+       vsb_new(&vsb, o->http.s, len, VSB_FIXEDLEN);
+       vsb_printf(&vsb, "\n");
+       vsb_printf(&vsb, "\n");
+       vsb_printf(&vsb, "HTTP/1.1\r\n");
+       vsb_printf(&vsb, "%d\n", status);
+       vsb_printf(&vsb, "%s\n", reason);
+       TIM_format(now, buf);
+       vsb_printf(&vsb, "Date: %s\n", buf);
+       vsb_printf(&vsb, "Server: Varnish\n");
+       vsb_printf(&vsb, "Retry-After: %ju\n", (uintmax_t)ttl);
+       vsb_printf(&vsb, "Content-Type: text/html; charset=utf-8\n");
+       vsb_printf(&vsb, "Content-Length: %ud\n", o->len);
+       vsb_finish(&vsb);
+       vsb_delete(&vsb);
+
+       /* XXX and here */
+       o->http.f = o->http.s;
+       o->http.nhd = 0;
+       do {
+               o->http.hd[o->http.nhd].b = o->http.f;
+               while (*o->http.f != '\n')
+                       ++o->http.f;
+               o->http.hd[o->http.nhd].e = o->http.f;
+               ++o->http.nhd;
+               ++o->http.f;
+       } while (*o->http.f);
+
+       return (0);
+}
 
 /*--------------------------------------------------------------------*/
 
index f9ea9ba3e681e12428152bc6a743c95dfc8be487..b470ddbe46a92a2cff394b50f8f2bfa91f33bcc7 100644 (file)
@@ -199,5 +199,5 @@ main(int argc, char **argv)
                        TAILQ_INSERT_BEFORE(tp, tp2, list);
                }
        }
-       return (0);
+       exit(0);
 }