From d68b67d85e08f5cb0d5d915c38aa6a5481e10219 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 6 Sep 2009 14:15:46 +0000 Subject: [PATCH] Disable connection-sharing unless FEATURE_CONNECTION_SHARING is defined. --- gateway.c | 18 +++++++++++++----- gateway.h | 10 ++++++---- jcc.c | 16 +++++++++++----- loadcfg.c | 8 ++++---- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/gateway.c b/gateway.c index 1bbb88d7..19a2947b 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.58 2009/08/19 15:22:18 fabiankeil Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.59 2009/09/06 14:09:19 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -125,7 +125,7 @@ struct socks_reply { static const char socks_userid[] = "anonymous"; -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING #define MAX_REUSABLE_CONNECTIONS 100 static unsigned int keep_alive_timeout = DEFAULT_KEEP_ALIVE_TIMEOUT; @@ -270,8 +270,10 @@ void remember_connection(const struct client_state *csp, const struct forward_sp privoxy_mutex_unlock(&connection_reuse_mutex); } +#endif /* def FEATURE_CONNECTION_SHARING */ +#ifdef FEATURE_CONNECTION_KEEP_ALIVE /********************************************************************* * * Function : mark_connection_closed @@ -300,8 +302,10 @@ void mark_connection_closed(struct reusable_connection *closed_connection) freez(closed_connection->forward_host); closed_connection->forward_port = 0; } +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#ifdef FEATURE_CONNECTION_SHARING /********************************************************************* * * Function : forget_connection @@ -345,8 +349,10 @@ void forget_connection(jb_socket sfd) privoxy_mutex_unlock(&connection_reuse_mutex); } +#endif /* def FEATURE_CONNECTION_SHARING */ +#ifdef FEATURE_CONNECTION_KEEP_ALIVE /********************************************************************* * * Function : connection_destination_matches @@ -396,8 +402,10 @@ int connection_destination_matches(const struct reusable_connection *connection, return (!strcmpic(connection->host, http->host)); } +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#ifdef FEATURE_CONNECTION_SHARING /********************************************************************* * * Function : close_unusable_connections @@ -579,7 +587,7 @@ void set_keep_alive_timeout(unsigned int timeout) { keep_alive_timeout = timeout; } -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#endif /* def FEATURE_CONNECTION_SHARING */ /********************************************************************* @@ -605,7 +613,7 @@ jb_socket forwarded_connect(const struct forward_spec * fwd, int dest_port; jb_socket sfd = JB_INVALID_SOCKET; -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING) && !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)) { @@ -615,7 +623,7 @@ jb_socket forwarded_connect(const struct forward_spec * fwd, return sfd; } } -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#endif /* def FEATURE_CONNECTION_SHARING */ /* Figure out if we need to connect to the web server or a HTTP proxy. */ if (fwd->forward_host) diff --git a/gateway.h b/gateway.h index 0782257e..7e391783 100644 --- a/gateway.h +++ b/gateway.h @@ -1,6 +1,6 @@ #ifndef GATEWAY_H_INCLUDED #define GATEWAY_H_INCLUDED -#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.16 2009/05/16 13:27:20 fabiankeil Exp $" +#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.17 2009/07/11 14:49:09 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.h,v $ @@ -48,7 +48,6 @@ struct client_state; extern jb_socket forwarded_connect(const struct forward_spec * fwd, struct http_request *http, struct client_state *csp); -#ifdef FEATURE_CONNECTION_KEEP_ALIVE /* * Default number of seconds after which an @@ -56,18 +55,21 @@ extern jb_socket forwarded_connect(const struct forward_spec * fwd, */ #define DEFAULT_KEEP_ALIVE_TIMEOUT 180 +#ifdef FEATURE_CONNECTION_SHARING extern void set_keep_alive_timeout(unsigned int timeout); extern void initialize_reusable_connections(void); extern void forget_connection(jb_socket sfd); extern void remember_connection(const struct client_state *csp, const struct forward_spec *fwd); extern int close_unusable_connections(void); +#endif /* FEATURE_CONNECTION_SHARING */ + +#ifdef FEATURE_CONNECTION_KEEP_ALIVE extern void mark_connection_closed(struct reusable_connection *closed_connection); extern int connection_destination_matches(const struct reusable_connection *connection, const struct http_request *http, const struct forward_spec *fwd); -#endif /* FEATURE_CONNECTION_KEEP_ALIVE */ - +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ /* * Solaris fix diff --git a/jcc.c b/jcc.c index 79c76abd..274124f1 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.283 2009/09/05 18:04:37 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.284 2009/09/06 14:07:56 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1026,6 +1026,7 @@ static int server_response_is_complete(struct client_state *csp, } +#ifdef FEATURE_CONNECTION_SHARING /********************************************************************* * * Function : wait_for_alive_connections @@ -1053,6 +1054,7 @@ static void wait_for_alive_connections(void) log_error(LOG_LEVEL_CONNECT, "No connections to wait for left."); } +#endif /* def FEATURE_CONNECTION_SHARING */ /********************************************************************* @@ -2443,7 +2445,9 @@ static void serve(struct client_state *csp) #endif /* def AMIGA */ { #ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING static int monitor_thread_running = 0; +#endif /* def FEATURE_CONNECTION_SHARING */ int continue_chatting = 0; unsigned int latency = 0; @@ -2513,6 +2517,7 @@ static void serve(struct client_state *csp) { log_error(LOG_LEVEL_CONNECT, "No additional client request received in time."); +#ifdef FEATURE_CONNECTION_SHARING if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING) && (socket_is_still_usable(csp->sfd))) { @@ -2531,6 +2536,7 @@ static void serve(struct client_state *csp) } privoxy_mutex_unlock(&connection_reuse_mutex); } +#endif /* def FEATURE_CONNECTION_SHARING */ break; } } @@ -2549,9 +2555,9 @@ static void serve(struct client_state *csp) if (csp->sfd != JB_INVALID_SOCKET) { -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING forget_connection(csp->sfd); -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#endif /* def FEATURE_CONNECTION_SHARING */ close_socket(csp->sfd); } @@ -3301,13 +3307,13 @@ static void listen_loop(void) config = load_config(); -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING /* * XXX: Should be relocated once it no * longer needs to emit log messages. */ initialize_reusable_connections(); -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ +#endif /* def FEATURE_CONNECTION_SHARING */ bfd = bind_port_helper(config); diff --git a/loadcfg.c b/loadcfg.c index 62b943df..c0417aee 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.103 2009/06/15 20:50:56 fabiankeil Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.104 2009/07/19 10:07:46 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -500,7 +500,7 @@ struct configuration_spec * load_config(void) /* ************************************************************************* * connection-sharing (0|1) * *************************************************************************/ -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING case hash_connection_sharing : if ((*arg != '\0') && (0 != atoi(arg))) { @@ -1321,7 +1321,7 @@ struct configuration_spec * load_config(void) } } -#ifdef FEATURE_CONNECTION_KEEP_ALIVE +#ifdef FEATURE_CONNECTION_SHARING if (config->feature_flags & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE) { if (config->multi_threaded) @@ -1349,7 +1349,7 @@ struct configuration_spec * load_config(void) "has no effect if keep-alive-timeout isn't set."); config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING; } -#endif +#endif /* def FEATURE_CONNECTION_SHARING */ if (NULL == config->proxy_args) { -- 2.39.2