Commit 0ba6aeb4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add accept filters


git-svn-id: http://www.varnish-cache.org/svn/trunk@340 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e2a15f6a
......@@ -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>
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment