--- a
+++ b/sighttpd-maxlistners.patch
@@ -0,0 +1,121 @@
+diff -rupN sighttpd/src/http-response.c sighttpd.mod/src/http-response.c
+--- sighttpd/src/http-response.c	2012-06-15 18:00:02.188820357 +0200
++++ sighttpd.mod/src/http-response.c	2012-06-15 18:26:07.731116519 +0200
+@@ -93,6 +93,12 @@ respond_method_not_allowed (const char *
+ }
+ 
+ static void
++respond_service_unavailable (const char ** status_line, params_t ** response_headers)
++{
++        *status_line = http_status_line (HTTP_STATUS_SERVICE_UNAVAILABLE);
++}
++
++static void
+ respond (struct sighttpd_child * schild, http_request * request, params_t * request_headers)
+ {
+         params_t * response_headers;
+@@ -100,22 +106,25 @@ respond (struct sighttpd_child * schild,
+ 
+         response_headers = response_headers_new ();
+ 
+-        switch (request->method) {
+-        case HTTP_METHOD_HEAD:
+-        case HTTP_METHOD_GET:
+-                respond_get_head (schild, request, request_headers, &status_line, &response_headers);
+-                break;
+-        default:
+-                respond_method_not_allowed (&status_line, &response_headers);
+-                break;
+-        }
++	switch (request->method) {
++	case HTTP_METHOD_HEAD:
++	case HTTP_METHOD_GET:
++		if(schild->service_unavailable)
++			respond_service_unavailable (&status_line, &response_headers);
++		else 
++	        	respond_get_head (schild, request, request_headers, &status_line, &response_headers);
++	        break;
++	default:
++	        respond_method_not_allowed (&status_line, &response_headers);
++	        break;
++	}
+ 
+         write (schild->accept_fd, status_line, strlen(status_line));
+         params_writefd (schild->accept_fd, response_headers);
+ 
+         log_access (request, request_headers, response_headers);
+ 
+-        if (request->method == HTTP_METHOD_GET) {
++        if (request->method == HTTP_METHOD_GET && schild->service_unavailable == 0 ) {
+                 respond_get_body (schild, request, request_headers);
+         }
+ 
+
+diff -rupN sighttpd/src/sighttpd.c sighttpd.mod/src/sighttpd.c
+--- sighttpd/src/sighttpd.c	2012-06-15 18:00:02.198820371 +0200
++++ sighttpd.mod/src/sighttpd.c	2012-06-15 18:02:16.449017281 +0200
+@@ -26,6 +26,7 @@ struct sighttpd * sighttpd_init (struct
+ {
+         struct sighttpd * sighttpd;
+         const char *portname;
++	const char *max_listeners;
+         int port;
+ 
+         if ((sighttpd = malloc (sizeof(*sighttpd))) == NULL)
+@@ -51,6 +52,15 @@ struct sighttpd * sighttpd_init (struct
+                 port = atoi(portname);
+         }
+ 
++	max_listeners = dictionary_lookup (cfg->dictionary, "MaxListeners");
++	if (max_listeners == NULL) {
++		sighttpd->max_listeners = 0;
++	} else {
++		sighttpd->max_listeners = atoi(max_listeners);
++	}
++
++	sighttpd->cur_listeners = 0;
++
+         sighttpd->port = port;
+ 
+ 	sighttpd->resources = cfg->resources;
+@@ -78,6 +88,13 @@ sighttpd_child_new (struct sighttpd * si
+         if ((schild = malloc (sizeof(*schild))) == NULL)
+                 return NULL;
+ 
++	sighttpd->cur_listeners ++;
++
++	if( sighttpd->max_listeners > 0 && sighttpd->cur_listeners > sighttpd->max_listeners )
++		schild->service_unavailable = 1;
++	else 
++		schild->service_unavailable = 0;
++	
+         schild->sighttpd = sighttpd;
+         schild->accept_fd = accept_fd;
+ 
+@@ -88,5 +105,8 @@ void
+ sighttpd_child_destroy (struct sighttpd_child * schild)
+ {
+         close (schild->accept_fd);
++	if( schild->sighttpd->cur_listeners > 0 )
++		schild->sighttpd->cur_listeners --;
++
+         free (schild);
+ }
+diff -rupN sighttpd/src/sighttpd.h sighttpd.mod/src/sighttpd.h
+--- sighttpd/src/sighttpd.h	2012-06-15 18:00:02.198820371 +0200
++++ sighttpd.mod/src/sighttpd.h	2012-06-15 17:59:23.288763297 +0200
+@@ -7,11 +7,14 @@
+ struct sighttpd {
+ 	int port;
+ 	list_t * resources;
++	int cur_listeners;
++	int max_listeners;
+ };
+ 
+ struct sighttpd_child {
+         struct sighttpd * sighttpd;
+         int accept_fd;
++	int service_unavailable;
+ };
+ 
+ struct sighttpd * sighttpd_init (struct cfg * cfg);