From 159679fe850a0c96e3d85afb22c6e728a3da1a75 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 6 Jul 2006 08:45:23 +0000 Subject: [PATCH] Add accept filters git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@340 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/tcp.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/tcp.c b/varnish-cache/bin/varnishd/tcp.c index 368c0fd0..e6e0e5c7 100644 --- a/varnish-cache/bin/varnishd/tcp.c +++ b/varnish-cache/bin/varnishd/tcp.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -12,6 +13,21 @@ #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); } -- 2.39.5