]> err.no Git - varnish/commitdiff
Add accept filters
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Jul 2006 08:45:23 +0000 (08:45 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Jul 2006 08:45:23 +0000 (08:45 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@340 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/tcp.c

index 368c0fd00e0b251338edde1b482498e6877ccffd..e6e0e5c74b50ccf28a8f891f099c579e9e8c7177 100644 (file)
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <assert.h>
 #include <stdio.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include "heritage.h"
 #include "libvarnish.h"
 
+static void
+accept_filter(int fd)
+{
+       struct accept_filter_arg afa;
+       int i;
+
+       bzero(&afa, sizeof(afa));
+       strcpy(afa.af_name, "httpready");
+       errno = 0;
+       i = setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER,
+           &afa, sizeof(afa));
+       printf("Acceptfilter(%d, httpready): %d %s\n",
+           fd, i, strerror(errno));
+}
+
 static void
 create_listen_socket(const char *addr, const char *port, int *sp, int nsp)
 {
@@ -64,10 +80,14 @@ open_tcp(const char *port)
            &heritage.sock_remote[0], HERITAGE_NSOCKS);
 
        for (u = 0; u < HERITAGE_NSOCKS; u++) {
-               if (heritage.sock_local[u] >= 0)
+               if (heritage.sock_local[u] >= 0) {
                        AZ(listen(heritage.sock_local[u], 16));
-               if (heritage.sock_remote[u] >= 0)
+                       accept_filter(heritage.sock_local[u]);
+               }
+               if (heritage.sock_remote[u] >= 0) {
                        AZ(listen(heritage.sock_remote[u], 16));
+                       accept_filter(heritage.sock_remote[u]);
+               }
        }
        return (0);
 }