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);
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);
}
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);
}
/*--------------------------------------------------------------------*/
-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,
.alloc = smf_alloc,
.trim = smf_trim,
.free = smf_free,
- .send = smf_send
};
#ifdef INCLUDE_TEST_DRIVER