X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=7ca0f46f79e1d8e28a3434466b9011b8ff0707e0;hb=9b09b278a7ff6910f4334e5399bdb055882274a4;hp=8fb4e60540b30cf28f5d8de82bfb86d39a0aeaf8;hpb=6e59eba6ece20c3f85f8dd5408e5cae100765040;p=privoxy.git diff --git a/jcc.c b/jcc.c index 8fb4e605..7ca0f46f 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.239 2009/04/07 11:43:50 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.244 2009/04/17 11:34:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,23 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.239 2009/04/07 11:43:50 fabiankeil Exp $" * * Revisions : * $Log: jcc.c,v $ + * Revision 1.244 2009/04/17 11:34:34 fabiankeil + * Style cosmetics for the IPv6 code. + * + * Revision 1.243 2009/04/17 11:27:49 fabiankeil + * Petr Pisar's privoxy-3.0.12-ipv6-3.diff. + * + * Revision 1.242 2009/04/11 10:44:47 fabiankeil + * Update a comment. We're not in Kansas anymore. + * + * Revision 1.241 2009/04/11 10:37:23 fabiankeil + * When dropping connections due to ACL, don't leak csp->ip_addr_str. + * + * Revision 1.240 2009/04/09 10:12:54 fabiankeil + * Fix two cases in which an invalid server response would result + * in the client connection being closed without sending an error + * message first. + * * Revision 1.239 2009/04/07 11:43:50 fabiankeil * If the server rudely resets the connection directly after sending the * headers, pass the mess to the client instead of sending an incorrect @@ -2736,7 +2753,7 @@ static void chat(struct client_state *csp) if (fwd->forward_host) { - log_error(LOG_LEVEL_CONNECT, "via %s:%d to: %s", + log_error(LOG_LEVEL_CONNECT, "via [%s]:%d to: %s", fwd->forward_host, fwd->forward_port, http->hostport); } else @@ -4166,7 +4183,8 @@ static void listen_loop(void) { struct client_state *csp = NULL; jb_socket bfd; - struct configuration_spec * config; + struct configuration_spec *config; + unsigned int active_threads = 0; config = load_config(); @@ -4196,7 +4214,7 @@ static void listen_loop(void) /* * Free data that was used by died threads */ - sweep(); + active_threads = sweep(); #if defined(unix) /* @@ -4227,7 +4245,7 @@ static void listen_loop(void) { /* * Since we were listening to the "old port", we will not see - * a "listen" param change until the next IJB request. So, at + * a "listen" param change until the next request. So, at * least 1 more request must be made for us to find the new * setting. I am simply closing the old socket and binding the * new one. @@ -4281,11 +4299,26 @@ static void listen_loop(void) { log_error(LOG_LEVEL_CONNECT, "Connection from %s dropped due to ACL", csp->ip_addr_str); close_socket(csp->cfd); + freez(csp->ip_addr_str); freez(csp); continue; } #endif /* def FEATURE_ACL */ + if ((0 != config->max_client_connections) + && (active_threads >= config->max_client_connections)) + { + log_error(LOG_LEVEL_CONNECT, + "Rejecting connection from %s. Maximum number of connections reached.", + csp->ip_addr_str); + write_socket(csp->cfd, TOO_MANY_CONNECTIONS_RESPONSE, + strlen(TOO_MANY_CONNECTIONS_RESPONSE)); + close_socket(csp->cfd); + freez(csp->ip_addr_str); + freez(csp); + continue; + } + /* add it to the list of clients */ csp->next = clients->next; clients->next = csp;