r185 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jun 14 11:39:31 CEST 2006
Author: phk
Date: 2006-06-14 11:39:31 +0200 (Wed, 14 Jun 2006)
New Revision: 185
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Add vca_write_obj() which writes an sbuf (as) HTTP header and the
object from the sessions to the client.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-06-14 09:25:13 UTC (rev 184)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-06-14 09:39:31 UTC (rev 185)
@@ -59,6 +59,7 @@
/* cache_acceptor.c */
void vca_write(struct sess *sp, void *ptr, size_t len);
+void vca_write_obj(struct sess *sp, struct sbuf *hdr);
void vca_flush(struct sess *sp);
void vca_return_session(struct sess *sp);
void vca_close_session(struct sess *sp, const char *why);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2006-06-14 09:25:13 UTC (rev 184)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2006-06-14 09:39:31 UTC (rev 185)
@@ -84,6 +84,21 @@
sp->mem->liov += len;
}
+void
+vca_write_obj(struct sess *sp, struct sbuf *hdr)
+{
+ struct storage *st;
+
+ vca_write(sp, sbuf_data(hdr), sbuf_len(hdr));
+ TAILQ_FOREACH(st, &sp->obj->store, list) {
+ if (st->stevedore->send != NULL)
+ st->stevedore->send(st, sp);
+ else
+ vca_write(sp, st->ptr, st->len);
+ }
+ vca_flush(sp);
+}
+
/*--------------------------------------------------------------------*/
static void
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-14 09:25:13 UTC (rev 184)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-14 09:39:31 UTC (rev 185)
@@ -60,10 +60,9 @@
}
http_BuildSbuf(2, w->sb, hp);
- vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
- vca_write(sp, st->ptr, st->len);
- vca_flush(sp);
+ vca_write_obj(sp, w->sb);
+
hash->deref(sp->obj);
return (0);
@@ -126,11 +125,8 @@
}
http_BuildSbuf(2, w->sb, hp);
- vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
- TAILQ_FOREACH(st, &sp->obj->store, list)
- vca_write(sp, st->ptr, st->len);
- vca_flush(sp);
+ vca_write_obj(sp, w->sb);
hash->deref(sp->obj);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-06-14 09:25:13 UTC (rev 184)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-06-14 09:39:31 UTC (rev 185)
@@ -68,23 +68,15 @@
static int
DeliverSession(struct worker *w, struct sess *sp)
{
- char buf[BUFSIZ];
- struct storage *st;
- sprintf(buf,
+ sbuf_clear(w->sb);
+ sbuf_printf(w->sb,
"HTTP/1.1 200 OK\r\n"
"Server: Varnish\r\n"
"Content-Length: %u\r\n"
"\r\n", sp->obj->len);
- vca_write(sp, buf, strlen(buf));
- TAILQ_FOREACH(st, &sp->obj->store, list) {
- if (st->stevedore->send != NULL)
- st->stevedore->send(st, sp);
- else
- vca_write(sp, st->ptr, st->len);
- }
- vca_flush(sp);
+ vca_write_obj(sp, w->sb);
return (1);
}
More information about the varnish-commit
mailing list