r316 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Jul 5 11:56:35 CEST 2006


Author: phk
Date: 2006-07-05 11:56:35 +0200 (Wed, 05 Jul 2006)
New Revision: 316

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/stevedore.h
   trunk/varnish-cache/bin/varnishd/storage_file.c
Log:
Send headers with sendfile


Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-05 09:44:53 UTC (rev 315)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-05 09:56:35 UTC (rev 316)
@@ -36,7 +36,7 @@
 
 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 @@
 	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);
 	}

Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h	2006-07-05 09:44:53 UTC (rev 315)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h	2006-07-05 09:56:35 UTC (rev 316)
@@ -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;

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-05 09:44:53 UTC (rev 315)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-05 09:56:35 UTC (rev 316)
@@ -529,23 +529,26 @@
 /*--------------------------------------------------------------------*/
 
 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");
 }
 




More information about the varnish-commit mailing list