From d0136996edb3f0d5e339096a5c344b2be742c8e6 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 20 Oct 2008 20:02:48 +0000 Subject: [PATCH] Clean up some of the fallout from the Solaris patch - mostly configure script breakage. In particular, disable the sendfile() check, as Solaris doesn't have a working sendfile() any more than Linux does. Actually, the Solaris sendfile code was never compiled or used, because the #ifdefs in cache_pool.c were all wrong. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3338 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/Makefile.am | 3 +- varnish-cache/bin/varnishd/cache_pool.c | 6 +-- varnish-cache/bin/varnishd/storage_umem.c | 2 +- varnish-cache/configure.ac | 45 ++++++++++++++--------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/varnish-cache/bin/varnishd/Makefile.am b/varnish-cache/bin/varnishd/Makefile.am index b94a9d31..d4409a32 100644 --- a/varnish-cache/bin/varnishd/Makefile.am +++ b/varnish-cache/bin/varnishd/Makefile.am @@ -80,7 +80,7 @@ varnishd_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvcl/libvcl.la \ @JEMALLOC_LDADD@ \ - ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} + ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} ${LIBUMEM} EXTRA_DIST = default.vcl DISTCLEANFILES = default_vcl.h @@ -93,4 +93,3 @@ default_vcl.h: default.vcl Makefile # Explicitly record dependency mgt_vcc.c: default_vcl.h - diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 54facbaa..cbd8d8c3 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -193,8 +193,7 @@ WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len) sendfile(*w->wfd, fd, &off, len) != len) w->werr++; } while (0); -#elif defined(__sun) -#ifdef HAVE_SENDFILEV +#elif defined(__sun) && defined(HAVE_SENDFILEV) do { sendfilevec_t svvec[HTTP_HDR_MAX * 2 + 1]; size_t xferred = 0, expected = 0; @@ -217,13 +216,12 @@ WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len) w->liov = 0; w->niov = 0; } while (0); -#else +#elif defined(__sun) && defined(HAVE_SENDFILE) do { if (WRK_Flush(w) == 0 && sendfile(*w->wfd, fd, &off, len) != len) w->werr++; } while (0); -#endif #else #error Unknown sendfile() implementation #endif diff --git a/varnish-cache/bin/varnishd/storage_umem.c b/varnish-cache/bin/varnishd/storage_umem.c index e4d27b56..8912754f 100644 --- a/varnish-cache/bin/varnishd/storage_umem.c +++ b/varnish-cache/bin/varnishd/storage_umem.c @@ -33,7 +33,7 @@ #include "config.h" -#ifdef HAVE_UMEM_H +#ifdef HAVE_LIBUMEM #include diff --git a/varnish-cache/configure.ac b/varnish-cache/configure.ac index 12690460..23ed252f 100644 --- a/varnish-cache/configure.ac +++ b/varnish-cache/configure.ac @@ -70,8 +70,9 @@ AC_SUBST(LIBM) AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME -AC_CHECK_HEADERS([sys/socket.h]) +AC_CHECK_HEADERS([sys/filio.h]) AC_CHECK_HEADERS([sys/mount.h]) +AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([netinet/in.h]) @@ -109,7 +110,8 @@ AC_CHECK_FUNCS([pthread_set_name_np]) AC_CHECK_FUNCS([pthread_mutex_isowned_np]) LIBS="${save_LIBS}" -## This one is tricky, there are multiple versions +# sendfile is tricky: there are multiple versions, and most of them +# don't work. case $target in *-*-freebsd*) AC_CACHE_CHECK([whether sendfile works], @@ -125,28 +127,37 @@ case $target in [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 - ;; + ;; +#*-*-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 + +# Userland slab allocator, available only on Solaris +case $target in *-*-solaris*) - AC_CHECK_HEADERS([sys/filio.h]) - AC_CHECK_LIB(sendfile, sendfile) - AC_CHECK_LIB(umem, malloc) AC_CHECK_HEADERS([umem.h]) - - if test "$ac_cv_lib_sendfile_sendfile" = yes; then + if test "$ac_cv_have_umem_h" = yes; then save_LIBS="${LIBS}" - LIBS="${NET_LIBS}" - AC_CHECK_FUNCS([sendfile]) - AC_CHECK_FUNCS([sendfilev]) + LIBS="" + AC_CHECK_LIB(umem, umem_alloc) + LIBUMEM="${LIBS}" LIBS="${save_LIBS}" fi ;; -*) - AC_MSG_WARN([won't look for sendfile() on $target]) - ;; esac +AC_SUBST(LIBUMEM) # These functions are provided by libcompat on platforms where they # are not available -- 2.39.5