r340 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jul 6 10:45:23 CEST 2006


Author: phk
Date: 2006-07-06 10:45:23 +0200 (Thu, 06 Jul 2006)
New Revision: 340

Modified:
   trunk/varnish-cache/bin/varnishd/tcp.c
Log:
Add accept filters


Modified: trunk/varnish-cache/bin/varnishd/tcp.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/tcp.c	2006-07-06 08:43:53 UTC (rev 339)
+++ trunk/varnish-cache/bin/varnishd/tcp.c	2006-07-06 08:45:23 UTC (rev 340)
@@ -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>
@@ -13,6 +14,21 @@
 #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)
 {
 	struct addrinfo ai, *r0, *r1;
@@ -64,10 +80,14 @@
 	    &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);
 }




More information about the varnish-commit mailing list