-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 $
*
* 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
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
{
struct client_state *csp = NULL;
jb_socket bfd;
- struct configuration_spec * config;
+ struct configuration_spec *config;
+ unsigned int active_threads = 0;
config = load_config();
/*
* Free data that was used by died threads
*/
- sweep();
+ active_threads = sweep();
#if defined(unix)
/*
{
/*
* 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.
{
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;