From: phk Date: Wed, 5 Jul 2006 09:56:35 +0000 (+0000) Subject: Send headers with sendfile X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fbba3a7bae1863e2c35eab6d6dc47779397584c;p=varnish Send headers with sendfile git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@316 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index 5589b27c..08f223ad 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -36,7 +36,7 @@ static int pipes[2]; static pthread_t vca_thread; -#define SESS_IOVS 5 +#define SESS_IOVS 10 static struct event accept_e[2 * HERITAGE_NSOCKS]; @@ -108,10 +108,14 @@ vca_write_obj(struct worker *w, struct sess *sp) if (!strcmp(r, "GET")) { TAILQ_FOREACH(st, &sp->obj->store, list) { u += st->len; - if (st->stevedore->send != NULL) - st->stevedore->send(st, sp); - else + if (st->stevedore->send == NULL) { vca_write(sp, st->ptr, st->len); + continue; + } + st->stevedore->send(st, sp, + sp->mem->iov, sp->mem->niov, sp->mem->liov); + sp->mem->niov = 0; + sp->mem->liov = 0; } assert(u == sp->obj->len); } diff --git a/varnish-cache/bin/varnishd/stevedore.h b/varnish-cache/bin/varnishd/stevedore.h index 12269a94..6473922e 100644 --- a/varnish-cache/bin/varnishd/stevedore.h +++ b/varnish-cache/bin/varnishd/stevedore.h @@ -4,13 +4,14 @@ struct stevedore; struct sess; +struct iovec; typedef void storage_init_f(struct stevedore *, const char *spec); typedef void storage_open_f(struct stevedore *); typedef struct storage *storage_alloc_f(struct stevedore *, size_t size); typedef void storage_trim_f(struct storage *, size_t size); typedef void storage_free_f(struct storage *); -typedef void storage_send_f(struct storage *, struct sess *); +typedef void storage_send_f(struct storage *, struct sess *, struct iovec *, int niovec, size_t liovec); struct stevedore { const char *name; diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 94681e3c..a4926f3a 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -529,23 +529,26 @@ smf_free(struct storage *s) /*--------------------------------------------------------------------*/ static void -smf_send(struct storage *st, struct sess *sp) +smf_send(struct storage *st, struct sess *sp, struct iovec *iov, int niov, size_t liov) { struct smf *smf; int i; off_t sent; + struct sf_hdtr sfh; smf = st->priv; - vca_flush(sp); + memset(&sfh, 0, sizeof sfh); + sfh.headers = iov; + sfh.hdr_cnt = niov; i = sendfile(smf->sc->fd, sp->fd, smf->offset, - st->len, NULL, &sent, 0); - if (sent == st->len) + st->len, &sfh, &sent, 0); + if (sent == st->len + liov) return; - printf("sent i=%d sent=%ju size=%ju errno=%d\n", - i, (uintmax_t)sent, (uintmax_t)st->len, errno); + printf("sent i=%d sent=%ju size=%ju liov=%ju errno=%d\n", + i, (uintmax_t)sent, (uintmax_t)st->len, liov, errno); vca_close_session(sp, "remote closed"); }