]> err.no Git - varnish/commitdiff
Test whether SO_{RCV,SND}TIMEO work (they are defined but unimplemented
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 2 Nov 2007 14:09:17 +0000 (14:09 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 2 Nov 2007 14:09:17 +0000 (14:09 +0000)
on Solaris, so simply checking for their presence is not enough)

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2227 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/configure.ac

index 0b85e61e67d4cdf7f38ec6f99ab0afeb514b771e..9a82bc073ec73f8dcf9ee742fa1a8fc893262743 100644 (file)
@@ -90,17 +90,22 @@ sock_test(int fd)
        if (memcmp(&lin, &linger, l))
                need_linger = 1;
 
+#ifdef SO_SNDTIMEO_WORKS
        l = sizeof tv;
        AZ(getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l));
        assert(l == sizeof tv);
        if (memcmp(&tv, &tv_sndtimeo, l))
                need_sndtimeo = 1;
+#endif
 
+#ifdef SO_RCVTIMEO_WORKS
        l = sizeof tv;
        AZ(getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l));
        assert(l == sizeof tv);
        if (memcmp(&tv, &tv_rcvtimeo, l))
                need_rcvtimeo = 1;
+#endif
+
        need_test = 0;
 }
 
@@ -122,12 +127,16 @@ VCA_Prep(struct sess *sp)
        if (need_linger)
                AZ(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER,
                    &linger, sizeof linger));
+#ifdef SO_SNDTIMEO_WORKS
        if (need_sndtimeo)
                AZ(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO,
                    &tv_sndtimeo, sizeof tv_sndtimeo));
+#endif
+#ifdef SO_RCVTIMEO_WORKS
        if (need_rcvtimeo)
                AZ(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO,
                    &tv_rcvtimeo, sizeof tv_rcvtimeo));
+#endif
 }
 
 /*--------------------------------------------------------------------*/
@@ -160,6 +169,7 @@ vca_acct(void *arg)
 
        need_test = 1;
        while (1) {
+#ifdef SO_SNDTIMEO_WORKS
                if (params->send_timeout != tv_sndtimeo.tv_sec) {
                        need_test = 1;
                        tv_sndtimeo.tv_sec = params->send_timeout;
@@ -168,6 +178,8 @@ vca_acct(void *arg)
                                    SO_SNDTIMEO,
                                    &tv_sndtimeo, sizeof tv_sndtimeo));
                }
+#endif
+#ifdef SO_RCVTIMEO_WORKS
                if (params->sess_timeout != tv_rcvtimeo.tv_sec) {
                        need_test = 1;
                        tv_rcvtimeo.tv_sec = params->sess_timeout;
@@ -176,6 +188,7 @@ vca_acct(void *arg)
                                    SO_RCVTIMEO,
                                    &tv_rcvtimeo, sizeof tv_rcvtimeo));
                }
+#endif
                i = poll(pfd, heritage.nsocks, 1000);
                now = TIM_real();
                for (u = 0; u < heritage.nsocks; u++) {
index 495a54f3eefb940bcd45ecad449d3c382dbc4832..bfe4ca9d1ca6f0c6d57d2de2107a8f806a217bb1 100644 (file)
@@ -115,6 +115,45 @@ AC_CHECK_FUNCS([kqueue])
 AC_CHECK_FUNCS([epoll_ctl])
 AC_CHECK_FUNCS([poll])
 
+# Solaris defines SO_{RCV,SND}TIMEO, but does not implement them
+AC_CACHE_CHECK([whether SO_RCVTIMEO works],
+  [ac_cv_so_rcvtimeo_works],
+  [AC_RUN_IFELSE(
+    [AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+    ]],[[
+int sd = socket(AF_INET, SOCK_STREAM, 0);
+struct timeval tv = { 1, 0 };
+return !!setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
+    ]])],
+    [ac_cv_so_rcvtimeo_works=yes],
+    [ac_cv_so_rcvtime_works=no])
+  ])
+if test "$ac_cv_so_rcvtimeo_works" = yes; then
+   AC_DEFINE([SO_RCVTIMEO_WORKS], [1], [Define if SO_RCVTIMEO works])
+fi
+
+AC_CACHE_CHECK([whether SO_SNDTIMEO works],
+  [ac_cv_so_sndtimeo_works],
+  [AC_RUN_IFELSE(
+    [AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+    ]],[[
+int sd = socket(AF_INET, SOCK_STREAM, 0);
+struct timeval tv = { 1, 0 };
+return !!setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
+    ]])],
+    [ac_cv_so_sndtimeo_works=yes],
+    [ac_cv_so_sndtime_works=no])
+  ])
+if test "$ac_cv_so_sndtimeo_works" = yes; then
+   AC_DEFINE([SO_SNDTIMEO_WORKS], [1], [Define if SO_SNDTIMEO works])
+fi
+
 # Run-time directory
 VARNISH_STATE_DIR='${localstatedir}/varnish'
 AC_SUBST(VARNISH_STATE_DIR)