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

Remove sendfile(2) support, it doesn't seem to actually make any

difference in practice and complicates the code and increases the
size of storage data structures.
parent 23cffba4
......@@ -371,10 +371,6 @@ struct storage {
unsigned magic;
#define STORAGE_MAGIC 0x1a4e51c0
#ifdef SENDFILE_WORKS
int fd;
off_t where;
#endif
VTAILQ_ENTRY(storage) list;
struct stevedore *stevedore;
......@@ -916,9 +912,6 @@ unsigned WRW_Flush(struct worker *w);
unsigned WRW_FlushRelease(struct worker *w);
unsigned WRW_Write(struct worker *w, const void *ptr, int len);
unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf);
#ifdef SENDFILE_WORKS
void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
#endif /* SENDFILE_WORKS */
/* cache_session.c [SES] */
struct sess *SES_Alloc(void);
......
......@@ -220,20 +220,6 @@ res_WriteDirObj(const struct sess *sp, ssize_t low, ssize_t high)
ptr += len;
sp->wrk->acct_tmp.bodybytes += len;
#ifdef SENDFILE_WORKS
/*
* XXX: the overhead of setting up sendfile is not
* XXX: epsilon and maybe not even delta, so avoid
* XXX: engaging sendfile for small objects.
* XXX: Should use getpagesize() ?
*/
if (st->fd >= 0 &&
st->len >= cache_param->sendfile_threshold) {
VSC_C_main->n_objsendfile++;
WRW_Sendfile(sp->wrk, st->fd, st->where + off, len);
continue;
}
#endif /* SENDFILE_WORKS */
VSC_C_main->n_objwrite++;
(void)WRW_Write(sp->wrk, st->ptr + off, len);
}
......
......@@ -35,17 +35,6 @@
#include "config.h"
#include <sys/types.h>
#ifdef SENDFILE_WORKS
# if defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/socket.h>
# elif defined(__linux__)
# include <sys/sendfile.h>
# elif defined(__sun)
# include <sys/sendfile.h>
# else
# error Unknown sendfile() implementation
# endif
#endif /* SENDFILE_WORKS */
#include <sys/uio.h>
#include <stdio.h>
......@@ -290,69 +279,4 @@ WRW_EndChunk(struct worker *wrk)
}
#ifdef SENDFILE_WORKS
void
WRW_Sendfile(struct worker *wrk, int fd, off_t off, unsigned len)
{
struct wrw *wrw;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
wrw = &wrk->wrw;
AN(wrw->wfd);
assert(fd >= 0);
assert(len > 0);
#if defined(__FreeBSD__) || defined(__DragonFly__)
do {
struct sf_hdtr sfh;
memset(&sfh, 0, sizeof sfh);
if (wrw->niov > 0) {
sfh.headers = wrw->iov;
sfh.hdr_cnt = wrw->niov;
}
if (sendfile(fd, *wrw->wfd, off, len, &sfh, NULL, 0) != 0)
wrw->werr++;
wrw->liov = 0;
wrw->niov = 0;
} while (0);
#elif defined(__linux__)
do {
if (WRW_Flush(wrk) == 0 &&
sendfile(*wrw->wfd, fd, &off, len) != len)
wrw->werr++;
} while (0);
#elif defined(__sun) && defined(HAVE_SENDFILEV)
do {
sendfilevec_t svvec[cache_param->http_headers * 2 + 1];
size_t xferred = 0, expected = 0;
int i;
for (i = 0; i < wrw->niov; i++) {
svvec[i].sfv_fd = SFV_FD_SELF;
svvec[i].sfv_flag = 0;
svvec[i].sfv_off = (off_t) wrw->iov[i].iov_base;
svvec[i].sfv_len = wrw->iov[i].iov_len;
expected += svvec[i].sfv_len;
}
svvec[i].sfv_fd = fd;
svvec[i].sfv_flag = 0;
svvec[i].sfv_off = off;
svvec[i].sfv_len = len;
expected += svvec[i].sfv_len;
if (sendfilev(*wrw->wfd, svvec, i, &xferred) == -1 ||
xferred != expected)
wrw->werr++;
wrw->liov = 0;
wrw->niov = 0;
} while (0);
#elif defined(__sun) && defined(HAVE_SENDFILE)
do {
if (WRW_Flush(wrk) == 0 &&
sendfile(*wrw->wfd, fd, &off, len) != len)
wrw->werr++;
} while (0);
#else
#error Unknown sendfile() implementation
#endif
}
#endif /* SENDFILE_WORKS */
......@@ -102,10 +102,6 @@ struct params {
ssize_t fetch_maxchunksize;
unsigned nuke_limit;
#ifdef SENDFILE_WORKS
/* Sendfile object minimum size */
ssize_t sendfile_threshold;
#endif
/* VCL traces */
unsigned vcl_trace;
......
......@@ -863,13 +863,6 @@ static const struct parspec input_parspec[] = {
"fragmentation.\n",
EXPERIMENTAL,
"256m", "bytes" },
#ifdef SENDFILE_WORKS
{ "sendfile_threshold",
tweak_bytes, &mgt_param.sendfile_threshold, 0, 0,
"The minimum size of objects transmitted with sendfile.",
EXPERIMENTAL,
"1E", "bytes" },
#endif /* SENDFILE_WORKS */
{ "vcl_trace", tweak_bool, &mgt_param.vcl_trace, 0, 0,
"Trace VCL execution in the shmlog.\n"
"Enabling this will allow you to see the path each "
......
......@@ -482,10 +482,6 @@ smf_alloc(struct stevedore *st, size_t size)
smf->s.ptr = smf->ptr;
smf->s.len = 0;
smf->s.stevedore = st;
#ifdef SENDFILE_WORKS
smf->s.fd = smf->sc->fd;
smf->s.where = smf->offset;
#endif
return (&smf->s);
}
......
......@@ -117,9 +117,6 @@ sma_alloc(struct stevedore *st, size_t size)
sma->s.priv = sma;
sma->s.len = 0;
sma->s.space = size;
#ifdef SENDFILE_WORKS
sma->s.fd = -1;
#endif
sma->s.stevedore = st;
sma->s.magic = STORAGE_MAGIC;
return (&sma->s);
......
......@@ -450,9 +450,6 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
ss->space = max_size;
ss->priv = sc;
ss->stevedore = st;
#ifdef SENDFILE_WORKS
ss->fd = sc->fd;
#endif
if (ssg != NULL)
*ssg = sg;
return (ss);
......
......@@ -87,9 +87,6 @@ SMS_Makesynth(struct object *obj)
sto->priv = vsb;
sto->len = 0;
sto->space = 0;
#ifdef SENDFILE_WORKS
sto->fd = -1;
#endif
sto->stevedore = &sms_stevedore;
sto->magic = STORAGE_MAGIC;
......
......@@ -198,40 +198,6 @@ AC_CHECK_FUNCS([pthread_mutex_isowned_np])
AC_CHECK_FUNCS([pthread_timedjoin_np])
LIBS="${save_LIBS}"
# sendfile is tricky: there are multiple versions, and most of them
# don't work.
case $target in
*-*-freebsd*)
AC_CACHE_CHECK([whether sendfile works],
[ac_cv_so_sendfile_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
]],[[
return (SF_SYNC == 0);
]])],
[ac_cv_so_sendfile_works=yes],
[ac_cv_so_sendfile_works=no])
])
;;
#*-*-solaris*)
# save_LIBS="${LIBS}"
# LIBS="${NET_LIBS}"
# AC_CHECK_LIB(sendfile, sendfile)
# AC_CHECK_FUNCS([sendfile])
# AC_CHECK_FUNCS([sendfilev])
# NET_LIBS="${LIBS}"
# LIBS="${save_LIBS}"
*)
AC_MSG_WARN([won't look for sendfile() on $target])
;;
esac
if test "$ac_cv_so_sendfile_works" = yes; then
AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works])
fi
# Support for visibility attribute
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -Werror"
......
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