Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Merged revisions 1359-1387,1399 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1359 | phk | 2007-04-19 17:17:35 +0200 (Thu, 19 Apr 2007) | 9 lines
  
  When we have some amount of a chunk header, but not all of it, we
  need to read more from the fd.  The semantics we _really_ want for
  that read operation is "wait until at least one char is available,
  then return as many as N to us".
  
  This can be done with a combination of system calls, but it is likely
  just as cheap to just read one char at a time, so we do that.
........
  r1360 | des | 2007-04-21 19:48:21 +0200 (Sat, 21 Apr 2007) | 2 lines
  
  Clarify synopsis / description
........
  r1361 | des | 2007-04-21 19:52:44 +0200 (Sat, 21 Apr 2007) | 2 lines
  
  Style and whitespace cleanup + clarify comment explaining the log format
........
  r1362 | des | 2007-04-21 23:48:56 +0200 (Sat, 21 Apr 2007) | 12 lines
  
  Major rewrite of the VSL handler for increased robustness and clarity:
  
   - Treat all request fields in a similar manner.
  
   - Mostly eliminate fixed-size buffers.
  
   - Don't print or format anything until we see ReqEnd.
  
   - If we saw a Host: header, use it to generate an absolute URI,
     resulting in far more useful output when processing logs from a
     server which handles multiple virtual hosts.
........
  r1363 | des | 2007-04-22 15:09:59 +0200 (Sun, 22 Apr 2007) | 2 lines
  
  Further eliminate fixed-size buffers.
........
  r1364 | des | 2007-04-24 11:39:12 +0200 (Tue, 24 Apr 2007) | 6 lines
  
  Correctly detect the presence and location of all external library we use
  (except for the C math library, which the C standard guarantees is always
  available as -lm) and more importantly, use them only where needed.
  
  This should fix the compilation issues on SuSE.
........
  r1365 | des | 2007-04-24 14:23:37 +0200 (Tue, 24 Apr 2007) | 3 lines
  
  Move CFLAGS configuration to the bottom so it doesn't affect other tests.
  This makes --enable-werror work again.
........
  r1366 | des | 2007-04-24 14:36:58 +0200 (Tue, 24 Apr 2007) | 3 lines
  
  Move CFLAGS configuration to the bottom so it doesn't affect other tests.
  This makes --enable-werror work again.
........
  r1367 | des | 2007-04-24 14:37:58 +0200 (Tue, 24 Apr 2007) | 2 lines
  
  Eliminate warnings.
........
  r1368 | phk | 2007-04-26 08:54:58 +0200 (Thu, 26 Apr 2007) | 5 lines
  
  Add compat trick for clock_gettime()
  
  Submitted by:	Pierre Queinnec <pierre.queinnec@zenika.com>
........
  r1369 | des | 2007-04-26 12:39:19 +0200 (Thu, 26 Apr 2007) | 2 lines
  
  Force CONFIG_SHELL to /bin/sh.
........
  r1370 | des | 2007-05-01 19:48:56 +0200 (Tue, 01 May 2007) | 2 lines
  
  Add protective #ifdef.
........
  r1371 | des | 2007-05-01 19:55:13 +0200 (Tue, 01 May 2007) | 2 lines
  
  Improve the readability and debuggability of our tag conversion tricks.
........
  r1372 | des | 2007-05-01 19:55:31 +0200 (Tue, 01 May 2007) | 8 lines
  
  Two minor logging fixes:
   
   - change the type of vsl_handler()'s tag argument from unsigned int to
     enum shmlogtag to allow gcc to check switch statements and gdb to show
     its value by name rather than by number.
   
   - fix the "missing newline after VCL_call" bug in varnishlog (#95)
........
  r1373 | des | 2007-05-01 20:21:53 +0200 (Tue, 01 May 2007) | 4 lines
  
  Add and document a ping_interval parameter which controls the interval at
  which the parent pings the child.  Also document pipe_timeout, which was
  left out of the man page by accident.
........
  r1374 | des | 2007-05-02 14:20:43 +0200 (Wed, 02 May 2007) | 4 lines
  
  Try fixing #95 again.  The trick is that if we get a new SLT_VCL_call
  while the F_INVCL flag is set, we need to insert a newline before the
  entry for the new VCL_call.
........
  r1375 | des | 2007-05-02 15:56:24 +0200 (Wed, 02 May 2007) | 2 lines
  
  Correct the URL in the error page.
........
  r1376 | des | 2007-05-02 16:37:42 +0200 (Wed, 02 May 2007) | 6 lines
  
  Don't try to lock the objhead mutex if we don't have an objhead.  Doing so
  caused the Varnish child to die immediately after sending its 503 response
  if the backend didn't respond.
  
  Reviewed by:	phk
........
  r1377 | des | 2007-05-03 10:41:01 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1378 | des | 2007-05-03 10:45:33 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1379 | des | 2007-05-03 10:48:43 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1380 | des | 2007-05-03 10:48:51 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/explicit/ to circumvent a bug in gcc 3.
........
  r1381 | phk | 2007-05-04 14:25:23 +0200 (Fri, 04 May 2007) | 2 lines
  
  Fix error reporting with -C
........
  r1382 | des | 2007-05-04 14:28:56 +0200 (Fri, 04 May 2007) | 2 lines
  
  Apply the workaround suggested in #102.
........
  r1383 | des | 2007-05-05 16:08:01 +0200 (Sat, 05 May 2007) | 2 lines
  
  Whitespace nits
........
  r1384 | des | 2007-05-05 16:09:23 +0200 (Sat, 05 May 2007) | 2 lines
  
  Typo in comment
........
  r1385 | des | 2007-05-05 16:35:58 +0200 (Sat, 05 May 2007) | 2 lines
  
  Remove superfluous vsb_printf() argument
........
  r1386 | des | 2007-05-05 16:44:37 +0200 (Sat, 05 May 2007) | 2 lines
  
  Look for s-maxage before max-age.  This may need to be revisited.
........
  r1387 | des | 2007-05-06 20:57:26 +0200 (Sun, 06 May 2007) | 2 lines
  
  Update the default configuration.
........
  r1399 | des | 2007-05-09 16:37:04 +0200 (Wed, 09 May 2007) | 2 lines
  
  Correctly detect more incompatible automake versions.
........


git-svn-id: http://www.varnish-cache.org/svn/branches/1.0@1401 d4fa192b-c00b-0410-8231-f00ffab90ce4
  • Loading branch information
dag-erling committed May 10, 2007
1 parent 6c0211b commit 7c9edeb
Show file tree
Hide file tree
Showing 33 changed files with 433 additions and 208 deletions.
2 changes: 2 additions & 0 deletions autogen.des
Expand Up @@ -7,8 +7,10 @@ set -ex

./autogen.sh

CONFIG_SHELL=/bin/sh \
./configure \
--enable-developer-warnings \
--enable-debugging-symbols \
--enable-dependency-tracking \
--enable-werror \
--prefix=/opt/varnish
2 changes: 1 addition & 1 deletion autogen.sh
Expand Up @@ -15,7 +15,7 @@ if [ -z "$automake_version" ] ; then
exit 1
else
case $automake_version in
0.*|1.[0-8])
0.*|1.[0-8]|1.[0-8][.-]*)
echo "your version of automake ($automake_version) is too old;" \
"you need 1.9 or newer."
exit 1
Expand Down
3 changes: 2 additions & 1 deletion bin/varnishd/Makefile.am
Expand Up @@ -61,4 +61,5 @@ varnishd_LDFLAGS = -export-dynamic
varnishd_LDADD = \
$(top_builddir)/lib/libcompat/libcompat.a \
$(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvcl/libvcl.la
$(top_builddir)/lib/libvcl/libvcl.la \
${DL_LIBS} ${RT_LIBS} ${PTHREAD_LIBS}
4 changes: 2 additions & 2 deletions bin/varnishd/cache.h
Expand Up @@ -275,7 +275,7 @@ struct sess {
unsigned handling;
unsigned char wantbody;
int err_code;
const char *err_expl;
const char *err_reason;

TAILQ_ENTRY(sess) list;

Expand Down Expand Up @@ -428,7 +428,7 @@ void WSL_Flush(struct worker *w);
#endif

/* cache_response.c */
void RES_Error(struct sess *sp, int code, const char *expl);
void RES_Error(struct sess *sp, int code, const char *reason);
void RES_WriteObj(struct sess *sp);

/* cache_vcl.c */
Expand Down
7 changes: 0 additions & 7 deletions bin/varnishd/cache_acceptor_epoll.c
Expand Up @@ -70,13 +70,6 @@ vca_del(int fd)
AZ(epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &ev));
}

static void
vca_rcvhdev(struct sess *sp)
{

CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
}

static void *
vca_main(void *arg)
{
Expand Down
4 changes: 4 additions & 0 deletions bin/varnishd/cache_backend.c
Expand Up @@ -48,6 +48,10 @@
#include <sys/select.h>
#include <sys/ioctl.h>

#ifndef HAVE_CLOCK_GETTIME
#include "compat/clock_gettime.h"
#endif

#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
Expand Down
11 changes: 8 additions & 3 deletions bin/varnishd/cache_center.c
Expand Up @@ -74,6 +74,10 @@ DOT start -> RECV [style=bold,color=green,weight=4]
#include "compat/clock_gettime.h"
#endif

#ifndef HAVE_SRANDOMDEV
#include "compat/srandomdev.h"
#endif

#include "shmlog.h"
#include "vcl.h"
#include "cache.h"
Expand Down Expand Up @@ -243,9 +247,9 @@ static int
cnt_error(struct sess *sp)
{

RES_Error(sp, sp->err_code, sp->err_expl);
RES_Error(sp, sp->err_code, sp->err_reason);
sp->err_code = 0;
sp->err_expl = NULL;
sp->err_reason = NULL;
sp->step = STP_DONE;
return (0);
}
Expand Down Expand Up @@ -653,7 +657,8 @@ cnt_recv(struct sess *sp)

VCL_recv_method(sp);

sp->wantbody = !strcmp(sp->http->hd[HTTP_HDR_REQ].b, "GET");
sp->wantbody = (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "GET") ||
!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "POST"));
switch(sp->handling) {
case VCL_RET_LOOKUP:
/* XXX: discard req body, if any */
Expand Down
19 changes: 17 additions & 2 deletions bin/varnishd/cache_fetch.c
Expand Up @@ -113,7 +113,22 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp)
/* If we didn't succeed, add to buffer, try again */
if (q == NULL || q == buf || *q != '\n') {
xxxassert(be > bp);
i = http_Read(hp, fd, bp, be - bp);
/*
* The sematics we need here is "read until you have
* received at least one character, but feel free to
* return up to (be-bp) if they are available, but do
* not wait for those extra characters.
*
* The canonical way to do that is to do a blocking
* read(2) of one char, then change to nonblocking,
* read as many as we find, then change back to
* blocking reads again.
*
* Hardly much more efficient and certainly a good
* deal more complex than reading a single character
* at a time.
*/
i = http_Read(hp, fd, bp, 1);
if (i <= 0)
return (-1);
bp += i;
Expand Down Expand Up @@ -296,13 +311,13 @@ Fetch(struct sess *sp)
/* XXX: cleanup */
return (1);
}

CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);

sp->obj->entered = time(NULL);


assert(sp->obj->busy != 0);

if (http_GetHdr(vc->http, H_Last_Modified, &b))
Expand Down
10 changes: 8 additions & 2 deletions bin/varnishd/cache_hash.c
Expand Up @@ -185,16 +185,22 @@ HSH_Lookup(struct sess *sp)
void
HSH_Unbusy(struct object *o)
{
struct objhead *oh;
struct sess *sp;

CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy);
assert(o->refcnt > 0);
if (o->cacheable)
EXP_Insert(o);
LOCK(&o->objhead->mtx);
oh = o->objhead;
if (oh != NULL) {
CHECK_OBJ(oh, OBJHEAD_MAGIC);
LOCK(&oh->mtx);
}
o->busy = 0;
UNLOCK(&o->objhead->mtx);
if (oh != NULL)
UNLOCK(&oh->mtx);
while (1) {
sp = TAILQ_FIRST(&o->waitinglist);
if (sp == NULL)
Expand Down
16 changes: 10 additions & 6 deletions bin/varnishd/cache_http.c
Expand Up @@ -77,7 +77,7 @@ static enum shmlogtag logmtx[3][7] = {
};

static enum shmlogtag
T(struct http *hp, enum httptag t)
http2shmlog(struct http *hp, enum httptag t)
{

CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
Expand All @@ -86,8 +86,12 @@ T(struct http *hp, enum httptag t)
return (logmtx[hp->logtag][t]);
}

#define WSLH(wx, ax, bx, cx, dx) \
WSLR(wx, T((cx), (ax)), (bx), (cx)->hd[(dx)].b, (cx)->hd[(dx)].e);
static void
WSLH(struct worker *w, enum httptag t, unsigned xid, struct http *hp, int hdr)
{

WSLR(w, http2shmlog(hp, t), xid, hp->hd[hdr].b, hp->hd[hdr].e);
}

/*--------------------------------------------------------------------*/

Expand Down Expand Up @@ -372,7 +376,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p)
hp->nhd++;
} else {
VSL_stats->losthdr++;
WSLR(w, T(hp, HTTP_T_LostHeader), fd, p, q);
WSLR(w, http2shmlog(hp, HTTP_T_LostHeader), fd, p, q);
}
}
assert(hp->t <= hp->v);
Expand Down Expand Up @@ -803,7 +807,7 @@ http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr)
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
if (to->nhd >= HTTP_HDR_MAX) {
VSL_stats->losthdr++;
WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", hdr);
WSL(w, http2shmlog(to, HTTP_T_LostHeader), fd, "%s", hdr);
return;
}
http_seth(w, fd, to, to->nhd++, HTTP_T_Header, hdr);
Expand All @@ -823,7 +827,7 @@ http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ..
n = vsnprintf(to->f, l, fmt, ap);
if (n + 1 > l || to->nhd >= HTTP_HDR_MAX) {
VSL_stats->losthdr++;
WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", to->f);
WSL(w, http2shmlog(to, HTTP_T_LostHeader), fd, "%s", to->f);
} else {
assert(to->f < to->e);
to->hd[to->nhd].b = to->f;
Expand Down
24 changes: 12 additions & 12 deletions bin/varnishd/cache_response.c
Expand Up @@ -48,7 +48,7 @@
static struct http_msg {
unsigned nbr;
const char *txt;
const char *expl;
const char *reason;
} http_msg[] = {
{ 101, "Switching Protocols" },
{ 200, "OK" },
Expand Down Expand Up @@ -96,7 +96,7 @@ static struct http_msg {
/*--------------------------------------------------------------------*/

void
RES_Error(struct sess *sp, int code, const char *expl)
RES_Error(struct sess *sp, int code, const char *reason)
{
char buf[40];
struct vsb *sb;
Expand All @@ -115,13 +115,13 @@ RES_Error(struct sess *sp, int code, const char *expl)
if (mp->nbr > code)
break;
msg = mp->txt;
if (expl == NULL)
expl = mp->expl;
if (reason == NULL)
reason = mp->reason;
break;
}
if (expl == NULL)
expl = msg;
AN(expl);
if (reason == NULL)
reason = msg;
AN(reason);
AN(msg);

sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
Expand All @@ -144,11 +144,11 @@ RES_Error(struct sess *sp, int code, const char *expl)
" </HEAD>\r\n"
" <BODY>\r\n");
vsb_printf(sb, " <H1>Error %03d %s</H1>\r\n", code, msg);
vsb_printf(sb, " <P>%s</P>\r\n", expl);
vsb_printf(sb, " <H3>Guru Meditation:</H3>\r\n", expl);
vsb_printf(sb, " <P>%s</P>\r\n", reason);
vsb_printf(sb, " <H3>Guru Meditation:</H3>\r\n");
vsb_printf(sb, " <P>XID: %u</P>\r\n", sp->xid);
vsb_cat(sb,
" <I><A href=\"http://varnish.linpro.no/\">Varnish</A></I>\r\n"
" <I><A href=\"http://www.varnish-cache.org/\">Varnish</A></I>\r\n"
" </BODY>\r\n"
"</HTML>\r\n");
vsb_finish(sb);
Expand All @@ -158,7 +158,7 @@ RES_Error(struct sess *sp, int code, const char *expl)
WSL(sp->wrk, SLT_TxStatus, sp->id, "%d", code);
WSL(sp->wrk, SLT_TxProtocol, sp->id, "HTTP/1.1");
WSL(sp->wrk, SLT_TxResponse, sp->id, msg);
vca_close_session(sp, expl);
vca_close_session(sp, reason);
vsb_delete(sb);
}

Expand Down Expand Up @@ -255,7 +255,7 @@ RES_WriteObj(struct sess *sp)
sp->wrk->acct.bodybytes += st->len;
#ifdef HAVE_SENDFILE
/*
* XXX: the overhead of setting up senddile is not
* XXX: the overhead of setting up sendfile is not
* XXX: epsilon and maybe not even delta, so avoid
* XXX: engaging sendfile for small objects.
* XXX: Should use getpagesize() ?
Expand Down
6 changes: 3 additions & 3 deletions bin/varnishd/cache_vrt.c
Expand Up @@ -47,13 +47,13 @@
/*--------------------------------------------------------------------*/

void
VRT_error(struct sess *sp, unsigned code, const char *expl)
VRT_error(struct sess *sp, unsigned code, const char *reason)
{

CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, expl);
WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason);
sp->err_code = code;
sp->err_expl = expl;
sp->err_reason = reason;
}

/*--------------------------------------------------------------------*/
Expand Down
3 changes: 3 additions & 0 deletions bin/varnishd/heritage.h
Expand Up @@ -111,6 +111,9 @@ struct params {
/* HTTP proto behaviour */
unsigned backend_http11;
unsigned client_http11;

/* Ping interval */
unsigned ping_interval;
};

extern volatile struct params *params;
Expand Down
16 changes: 9 additions & 7 deletions bin/varnishd/mgt_child.c
Expand Up @@ -214,13 +214,15 @@ start_child(void)
ev_listen = e;

AZ(ev_poker);
e = ev_new();
XXXAN(e);
e->timeout = 3.0;
e->callback = child_poker;
e->name = "child poker";
AZ(ev_add(mgt_evb, e));
ev_poker = e;
if (params->ping_interval > 0) {
e = ev_new();
XXXAN(e);
e->timeout = params->ping_interval;
e->callback = child_poker;
e->name = "child poker";
AZ(ev_add(mgt_evb, e));
ev_poker = e;
}

mgt_cli_start_child(heritage.fds[0], heritage.fds[3]);
AZ(close(heritage.fds[1]));
Expand Down
19 changes: 17 additions & 2 deletions bin/varnishd/mgt_param.c
Expand Up @@ -50,7 +50,7 @@ typedef void tweak_t(struct cli *, struct parspec *, const char *arg);
struct parspec {
const char *name;
tweak_t *func;
const char *expl;
const char *descr;
const char *def;
const char *units;
};
Expand Down Expand Up @@ -407,6 +407,15 @@ tweak_client_http11(struct cli *cli, struct parspec *par, const char *arg)

/*--------------------------------------------------------------------*/

static void
tweak_ping_interval(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
tweak_generic_uint(cli, &params->ping_interval, arg, 0, UINT_MAX);
}

/*--------------------------------------------------------------------*/

/*
* Make sure to end all lines with either a space or newline of the
* formatting will go haywire.
Expand Down Expand Up @@ -566,6 +575,12 @@ static struct parspec parspec[] = {
"backend response."
EXPERIMENTAL,
"off", "bool" },
{ "ping_interval", tweak_ping_interval,
"Interval between pings from parent to child.\n"
"Zero will disable pinging entirely, which makes "
"it possible to attach a debugger to the child.\n"
MUST_RESTART,
"3", "seconds" },
{ NULL, NULL, NULL }
};

Expand Down Expand Up @@ -602,7 +617,7 @@ mcf_param_show(struct cli *cli, char **av, void *priv)
if (av[2] != NULL) {
cli_out(cli, "%-20s Default is %s\n", "", pp->def);
/* Format text to 72 col width */
for (p = pp->expl; *p != '\0'; ) {
for (p = pp->descr; *p != '\0'; ) {
q = strchr(p, '\n');
if (q == NULL)
q = strchr(p, '\0');
Expand Down

0 comments on commit 7c9edeb

Please sign in to comment.