r118 - in trunk/varnish-cache: . bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Apr 5 11:40:22 CEST 2006
Author: phk
Date: 2006-04-05 11:40:22 +0200 (Wed, 05 Apr 2006)
New Revision: 118
Modified:
trunk/varnish-cache/autogen.sh
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_httpd.c
trunk/varnish-cache/bin/varnishd/cache_pass.c
trunk/varnish-cache/bin/varnishd/cache_pipe.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Account for the last byte of the header.
Modified: trunk/varnish-cache/autogen.sh
===================================================================
--- trunk/varnish-cache/autogen.sh 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/autogen.sh 2006-04-05 09:40:22 UTC (rev 118)
@@ -3,6 +3,8 @@
# $Id$
#
+set -ex
+
if [ -d /usr/local/gnu-autotools/bin ] ; then
PATH=${PATH}:/usr/local/gnu-autotools/bin
export PATH
@@ -10,6 +12,7 @@
base=$(cd $(dirname $0) && pwd)
for dir in $base $base/contrib/libevent ; do
+ (
echo $dir
cd $dir
aclocal
@@ -17,4 +20,14 @@
autoheader
automake --add-missing --copy --force --foreign
autoconf
+ )
done
+
+sh configure \
+ --enable-pedantic \
+ --enable-wall \
+ --enable-werror \
+ --enable-dependency-tracking
+
+# This is a safety-measure during development
+( cd lib/libvcl && ./*.tcl )
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-04-05 09:40:22 UTC (rev 118)
@@ -4,6 +4,16 @@
struct event_base;
+#ifdef EV_TIMEOUT
+struct worker {
+ struct event_base *eb;
+ struct event e1, e2;
+ struct sbuf *sb;
+};
+#else
+struct worker;
+#endif
+
/* cache_acceptor.c */
void *vca_main(void *arg);
void vca_retire_session(struct sess *sp);
@@ -22,10 +32,10 @@
pthread_mutex_t sessmtx;
/* cache_pass.c */
-void PassSession(struct sess *sp);
+void PassSession(struct worker *w, struct sess *sp);
/* cache_pipe.c */
-void PipeSession(struct sess *sp);
+void PipeSession(struct worker *w, struct sess *sp);
/* cache_pool.c */
void CacheInitPool(void);
Modified: trunk/varnish-cache/bin/varnishd/cache_httpd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpd.c 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/bin/varnishd/cache_httpd.c 2006-04-05 09:40:22 UTC (rev 118)
@@ -163,7 +163,7 @@
continue;
break;
}
- sp->hdr_end = p - sp->rcv;
+ sp->hdr_end = ++p - sp->rcv;
VSL(SLT_Debug, 0, "HTTP %u %u", sp->rcv_len, sp->hdr_end);
event_del(sp->rd_e);
sp->sesscb(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-04-05 09:40:22 UTC (rev 118)
@@ -31,71 +31,66 @@
/*--------------------------------------------------------------------*/
void
-PassSession(struct sess *sp)
+PassSession(struct worker *w, struct sess *sp)
{
int fd, i, j;
void *fd_token;
- struct sbuf *sb;
- struct event_base *eb;
struct sess sp2;
- struct event ev;
char buf[BUFSIZ];
off_t cl;
fd = VBE_GetFd(sp->backend, &fd_token);
assert(fd != -1);
- sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
- assert(sb != NULL);
- sbuf_cat(sb, sp->http.req);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp->http.url);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp->http.proto);
- sbuf_cat(sb, "\r\n");
+ sbuf_clear(w->sb);
+ assert(w->sb != NULL);
+ sbuf_cat(w->sb, sp->http.req);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp->http.url);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp->http.proto);
+ sbuf_cat(w->sb, "\r\n");
#define HTTPH(a, b, c, d, e, f, g) \
do { \
if (d && sp->http.b != NULL) { \
- sbuf_cat(sb, a ": "); \
- sbuf_cat(sb, sp->http.b); \
- sbuf_cat(sb, "\r\n"); \
+ sbuf_cat(w->sb, a ": "); \
+ sbuf_cat(w->sb, sp->http.b); \
+ sbuf_cat(w->sb, "\r\n"); \
} \
} while (0);
#include "http_headers.h"
#undef HTTPH
- sbuf_cat(sb, "\r\n");
- sbuf_finish(sb);
- i = write(fd, sbuf_data(sb), sbuf_len(sb));
- assert(i == sbuf_len(sb));
+ sbuf_cat(w->sb, "\r\n");
+ sbuf_finish(w->sb);
+ i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
+ assert(i == sbuf_len(w->sb));
memset(&sp2, 0, sizeof sp2);
- memset(&ev, 0, sizeof ev);
- sp2.rd_e = &ev;
+ sp2.rd_e = &w->e1;
sp2.fd = fd;
- eb = event_init();
- HttpdGetHead(&sp2, eb, PassReturn);
- event_base_loop(eb, 0);
- sbuf_clear(sb);
- sbuf_cat(sb, sp2.http.proto);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp2.http.status);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp2.http.response);
- sbuf_cat(sb, "\r\n");
+ HttpdGetHead(&sp2, w->eb, PassReturn);
+ event_base_loop(w->eb, 0);
+ sbuf_clear(w->sb);
+ sbuf_cat(w->sb, sp2.http.proto);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp2.http.status);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp2.http.response);
+ sbuf_cat(w->sb, "\r\n");
#define HTTPH(a, b, c, d, e, f, g) \
do { \
if (d && sp2.http.b != NULL) { \
- sbuf_cat(sb, a ": "); \
- sbuf_cat(sb, sp2.http.b); \
- sbuf_cat(sb, "\r\n"); \
+ sbuf_cat(w->sb, a ": "); \
+ sbuf_cat(w->sb, sp2.http.b); \
+ sbuf_cat(w->sb, "\r\n"); \
} \
} while (0);
#include "http_headers.h"
#undef HTTPH
- sbuf_cat(sb, "\r\n");
- sbuf_finish(sb);
- i = write(sp->fd, sbuf_data(sb), sbuf_len(sb));
- assert(i == sbuf_len(sb));
+ sbuf_cat(w->sb, "\r\n");
+ sbuf_finish(w->sb);
+ i = write(sp->fd, sbuf_data(w->sb), sbuf_len(w->sb));
+ assert(i == sbuf_len(w->sb));
if (sp2.http.H_Content_Length != NULL) {
cl = strtoumax(sp2.http.H_Content_Length, NULL, 0);
VSL(SLT_Debug, 0, "CL %ju %u %u", cl, sp->rcv_len, sp->hdr_end);
Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-04-05 09:40:22 UTC (rev 118)
@@ -42,55 +42,51 @@
}
void
-PipeSession(struct sess *sp)
+PipeSession(struct worker *w, struct sess *sp)
{
int fd, i;
void *fd_token;
- struct sbuf *sb;
- struct event_base *eb;
struct edir e1, e2;
fd = VBE_GetFd(sp->backend, &fd_token);
assert(fd != -1);
- sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
- assert(sb != NULL);
- sbuf_cat(sb, sp->http.req);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp->http.url);
+ sbuf_clear(w->sb);
+ assert(w->sb != NULL);
+ sbuf_cat(w->sb, sp->http.req);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp->http.url);
if (sp->http.proto != NULL) {
- sbuf_cat(sb, " ");
- sbuf_cat(sb, sp->http.proto);
+ sbuf_cat(w->sb, " ");
+ sbuf_cat(w->sb, sp->http.proto);
}
- sbuf_cat(sb, "\r\n");
+ sbuf_cat(w->sb, "\r\n");
#define HTTPH(a, b, c, d, e, f, g) \
do { \
if (sp->http.b != NULL) { \
- sbuf_cat(sb, a ": "); \
- sbuf_cat(sb, sp->http.b); \
- sbuf_cat(sb, "\r\n"); \
+ sbuf_cat(w->sb, a ": "); \
+ sbuf_cat(w->sb, sp->http.b); \
+ sbuf_cat(w->sb, "\r\n"); \
} \
} while (0);
#include "http_headers.h"
#undef HTTPH
- sbuf_cat(sb, "\r\n");
- sbuf_finish(sb);
- i = write(fd, sbuf_data(sb), sbuf_len(sb));
- assert(i == sbuf_len(sb));
+ sbuf_cat(w->sb, "\r\n");
+ sbuf_finish(w->sb);
+ i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
+ assert(i == sbuf_len(w->sb));
e1.fd = fd;
e2.fd = sp->fd;
- eb = event_init();
event_set(&e1.ev, sp->fd, EV_READ | EV_PERSIST, rdf, &e1);
- event_base_set(eb, &e1.ev);
+ event_base_set(w->eb, &e1.ev);
event_set(&e2.ev, fd, EV_READ | EV_PERSIST, rdf, &e2);
- event_base_set(eb, &e2.ev);
+ event_base_set(w->eb, &e2.ev);
event_add(&e1.ev, NULL);
event_add(&e2.ev, NULL);
- event_base_loop(eb, 0);
+ event_base_loop(w->eb, 0);
close (fd);
close (sp->fd);
- /* XXX: Delete eb */
VBE_ClosedFd(fd_token);
sp->fd = -1;
}
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-04-04 10:35:49 UTC (rev 117)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-04-05 09:40:22 UTC (rev 118)
@@ -3,9 +3,13 @@
*/
#include <stdio.h>
+#include <string.h>
#include <assert.h>
#include <pthread.h>
#include <queue.h>
+#include <sys/time.h>
+#include <sbuf.h>
+#include <event.h>
#include "libvarnish.h"
#include "vcl_lang.h"
@@ -19,7 +23,14 @@
CacheWorker(void *priv)
{
struct sess *sp;
+ struct worker w;
+ memset(&w, 0, sizeof w);
+ w.eb = event_init();
+ assert(w.eb != NULL);
+ w.sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ assert(w.sb != NULL);
+
(void)priv;
AZ(pthread_mutex_lock(&sessmtx));
while (1) {
@@ -42,9 +53,9 @@
printf("Handling: %d\n", sp->handling);
if (0) {
- PipeSession(sp);
+ PipeSession(&w, sp);
} else {
- PassSession(sp);
+ PassSession(&w, sp);
}
AZ(pthread_mutex_lock(&sessmtx));
More information about the varnish-commit
mailing list