find it, allow its use, but still default to off via sendfile_threshold
paramter.
SF_SYNC is only available in FreeBSD-current as of a few seconds
ago, and is unlikely to appear in any release before FreeBSD-8.0
for intricate reasons of ABI compliance.
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2417
d4fa192b-c00b-0410-8231-
f00ffab90ce4
unsigned WRK_Flush(struct worker *w);
unsigned WRK_Write(struct worker *w, const void *ptr, int len);
unsigned WRK_WriteH(struct worker *w, const txt *hh, const char *suf);
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
void WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
/* cache_session.c [SES] */
void SES_Init(void);
#include <sys/types.h>
#include <sys/uio.h>
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
#if defined(__FreeBSD__)
#include <sys/socket.h>
#elif defined(__linux__)
#else
#error Unknown sendfile() implementation
#endif
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
#include <errno.h>
#include <stdio.h>
return (len);
}
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
void
WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len)
{
#error Unknown sendfile() implementation
#endif
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
/*--------------------------------------------------------------------*/
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
u += st->len;
sp->wrk->acct.bodybytes += st->len;
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
/*
* XXX: the overhead of setting up sendfile is not
* XXX: epsilon and maybe not even delta, so avoid
st->where, st->len);
continue;
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
VSL_stats->n_objwrite++;
WRK_Write(sp->wrk, st->ptr, st->len);
}
/* Fetcher hints */
unsigned fetch_chunksize;
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
/* Sendfile object minimum size */
unsigned sendfile_threshold;
#endif
4, UINT_MAX / 1024);
}
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
/*--------------------------------------------------------------------*/
static void
(void)par;
tweak_generic_uint(cli, &master.sendfile_threshold, arg, 0, UINT_MAX);
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
/*--------------------------------------------------------------------*/
"above 128kb a dubious idea.",
EXPERIMENTAL,
"128", "kilobytes" },
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
{ "sendfile_threshold", tweak_sendfile_threshold,
"The minimum size of objects transmitted with sendfile.",
EXPERIMENTAL,
"-1", "bytes" },
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
{ "vcl_trace", tweak_vcl_trace,
"Trace VCL execution in the shmlog.\n"
"Enabling this will allow you to see the path each "
AC_CHECK_FUNCS([fmtcheck])
AC_CHECK_FUNCS([getdtablesize])
-# Don't look for sendfile at all, none of them work
-# anyway. (don't tell when done with passed mem-range)
-#
## This one is tricky, there are multiple versions
-#case $host in
-#*-*-freebsd*|*-*-linux*)
-# AC_CHECK_FUNCS([sendfile])
-# ;;
-#*)
-# AC_MSG_WARN([won't look for sendfile() on $host])
-# ;;
-#esac
+case $host 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])
+ ])
+ if test "$ac_cv_so_sendfile_works" = yes; then
+ AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works])
+ fi
+ ;;
+*)
+ AC_MSG_WARN([won't look for sendfile() on $host])
+ ;;
+esac
# These functions are provided by libcompat on platforms where they
# are not available