r2417 - in trunk/varnish-cache: . bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Feb 3 16:59:02 CET 2008
Author: phk
Date: 2008-02-03 16:59:01 +0100 (Sun, 03 Feb 2008)
New Revision: 2417
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/configure.ac
Log:
Look for the new SF_SYNC facility in FreeBSDs sendfile(2), and if we
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.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-02-03 15:59:01 UTC (rev 2417)
@@ -541,9 +541,9 @@
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);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-02-03 15:59:01 UTC (rev 2417)
@@ -34,7 +34,7 @@
#include <sys/types.h>
#include <sys/uio.h>
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
#if defined(__FreeBSD__)
#include <sys/socket.h>
#elif defined(__linux__)
@@ -42,7 +42,7 @@
#else
#error Unknown sendfile() implementation
#endif
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
#include <errno.h>
#include <stdio.h>
@@ -142,7 +142,7 @@
return (len);
}
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
void
WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len)
{
@@ -174,7 +174,7 @@
#error Unknown sendfile() implementation
#endif
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2008-02-03 15:59:01 UTC (rev 2417)
@@ -150,7 +150,7 @@
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
@@ -164,7 +164,7 @@
st->where, st->len);
continue;
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
VSL_stats->n_objwrite++;
WRK_Write(sp->wrk, st->ptr, st->len);
}
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-02-03 15:59:01 UTC (rev 2417)
@@ -98,7 +98,7 @@
/* Fetcher hints */
unsigned fetch_chunksize;
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
/* Sendfile object minimum size */
unsigned sendfile_threshold;
#endif
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-02-03 15:59:01 UTC (rev 2417)
@@ -371,7 +371,7 @@
4, UINT_MAX / 1024);
}
-#ifdef HAVE_SENDFILE
+#ifdef SENDFILE_WORKS
/*--------------------------------------------------------------------*/
static void
@@ -381,7 +381,7 @@
(void)par;
tweak_generic_uint(cli, &master.sendfile_threshold, arg, 0, UINT_MAX);
}
-#endif /* HAVE_SENDFILE */
+#endif /* SENDFILE_WORKS */
/*--------------------------------------------------------------------*/
@@ -699,12 +699,12 @@
"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 "
Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac 2008-02-02 10:58:05 UTC (rev 2416)
+++ trunk/varnish-cache/configure.ac 2008-02-03 15:59:01 UTC (rev 2417)
@@ -103,18 +103,30 @@
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
More information about the varnish-commit
mailing list