Commit 19404405 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Send headers with sendfile


git-svn-id: http://www.varnish-cache.org/svn/trunk@316 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d12d9ad6
......@@ -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);
}
......
......@@ -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;
......
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment