r708 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Aug 7 10:42:59 CEST 2006
Author: phk
Date: 2006-08-07 10:42:58 +0200 (Mon, 07 Aug 2006)
New Revision: 708
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/storage_malloc.c
Log:
First step of slow client handling: Lose the stevedore function
for sending and instead record the fd+off_t in the storage object.
This eliminates sendfile from storage_file.c, next step is to put
it back in the generic code in cache_response.c
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-08-07 05:52:50 UTC (rev 707)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-08-07 08:42:58 UTC (rev 708)
@@ -134,11 +134,15 @@
unsigned magic;
#define STORAGE_MAGIC 0x1a4e51c0
TAILQ_ENTRY(storage) list;
+ struct stevedore *stevedore;
+ void *priv;
+
unsigned char *ptr;
unsigned len;
unsigned space;
- void *priv;
- struct stevedore *stevedore;
+
+ int fd;
+ off_t where;
};
#include "stevedore.h"
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2006-08-07 05:52:50 UTC (rev 707)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2006-08-07 08:42:58 UTC (rev 708)
@@ -155,7 +155,6 @@
sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- /* XXX: conditional request handling */
if (sp->wantbody) {
TAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -163,15 +162,7 @@
assert(st->stevedore != NULL);
u += st->len;
sp->wrk->acct.bodybytes += st->len;
- if (st->stevedore->send == NULL) {
- WRK_Write(sp->wrk, st->ptr, st->len);
- } else {
- st->stevedore->send(st, sp);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- sp->wrk->niov = 0;
- sp->wrk->liov = 0;
- }
+ WRK_Write(sp->wrk, st->ptr, st->len);
}
assert(u == sp->obj->len);
}
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2006-08-07 05:52:50 UTC (rev 707)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2006-08-07 08:42:58 UTC (rev 708)
@@ -11,7 +11,6 @@
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 *);
struct stevedore {
const char *name;
@@ -20,7 +19,6 @@
storage_alloc_f *alloc;
storage_trim_f *trim;
storage_free_f *free;
- storage_send_f *send;
/* private fields */
void *priv;
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2006-08-07 05:52:50 UTC (rev 707)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2006-08-07 08:42:58 UTC (rev 708)
@@ -515,6 +515,8 @@
smf->s.ptr = smf->ptr;
smf->s.len = 0;
smf->s.stevedore = st;
+ smf->s.fd = smf->sc->fd;
+ smf->s.where = smf->offset;
CHECK_OBJ_NOTNULL(&smf->s, STORAGE_MAGIC);
return (&smf->s);
}
@@ -566,43 +568,6 @@
/*--------------------------------------------------------------------*/
-static void
-smf_send(struct storage *st, struct sess *sp)
-{
- struct smf *smf;
- int i;
- off_t sent;
- struct sf_hdtr sfh;
-
- CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- CAST_OBJ_NOTNULL(smf, st->priv, SMF_MAGIC);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- memset(&sfh, 0, sizeof sfh);
- sfh.headers = sp->wrk->iov;
- sfh.hdr_cnt = sp->wrk->niov;
- i = sendfile(smf->sc->fd,
- sp->fd,
- smf->offset,
- st->len, &sfh, &sent, 0);
-
- /* Check again after potentially long sleep */
- CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- CHECK_OBJ_NOTNULL(smf, SMF_MAGIC);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-
- if (sent == st->len + sp->wrk->liov)
- return;
- vca_close_session(sp, "remote closed");
- if (errno == EPIPE || errno == ENOTCONN)
- return;
- VSL(SLT_Debug, sp->fd,
- "sent i=%d sent=%ju size=%ju liov=%ju errno=%d\n",
- i, (uintmax_t)sent, (uintmax_t)st->len,
- (uintmax_t)sp->wrk->liov, errno);
-}
-
-/*--------------------------------------------------------------------*/
-
struct stevedore smf_stevedore = {
.name = "file",
.init = smf_init,
@@ -610,7 +575,6 @@
.alloc = smf_alloc,
.trim = smf_trim,
.free = smf_free,
- .send = smf_send
};
#ifdef INCLUDE_TEST_DRIVER
Modified: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-08-07 05:52:50 UTC (rev 707)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c 2006-08-07 08:42:58 UTC (rev 708)
@@ -24,6 +24,7 @@
assert(sma->s.ptr != NULL);
sma->s.len = 0;
sma->s.space = size;
+ sma->s.fd = -1;
sma->s.stevedore = st;
return (&sma->s);
}
More information about the varnish-commit
mailing list