-const char gateway_rcs[] = "$Id: gateway.c,v 1.40 2008/11/08 15:14:05 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.41 2008/11/08 15:29:58 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
*
* Revisions :
* $Log: gateway.c,v $
+ * Revision 1.41 2008/11/08 15:29:58 fabiankeil
+ * Unify two debug messages.
+ *
* Revision 1.40 2008/11/08 15:14:05 fabiankeil
* Fix duplicated debugging check.
*
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
#define MAX_REUSABLE_CONNECTIONS 100
-/* XXX: should be a config option. */
-#define CONNECTION_KEEP_ALIVE_TIMEOUT 3 * 60
+int keep_alive_timeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
struct reusable_connection
{
{
time_t time_open = time(NULL) - reusable_connection[slot].timestamp;
- if (CONNECTION_KEEP_ALIVE_TIMEOUT < time_open)
+ if (keep_alive_timeout < time_open)
{
log_error(LOG_LEVEL_CONNECT,
"The connection to %s:%d in slot %d timed out. "
- "Closing socket %d.", reusable_connection[slot].host,
+ "Closing socket %d. Timeout is: %d.",
+ reusable_connection[slot].host,
reusable_connection[slot].port, slot,
- reusable_connection[slot].sfd);
+ reusable_connection[slot].sfd, keep_alive_timeout);
close_socket(reusable_connection[slot].sfd);
mark_connection_closed(&reusable_connection[slot]);
continue;
return socket_found;
}
+
+
+/*********************************************************************
+ *
+ * Function : set_keep_alive_timeout
+ *
+ * Description : Sets the timeout after which open
+ * connections will no longer be reused.
+ *
+ * Parameters :
+ * 1 : timeout = The timeout in seconds.
+ *
+ * Returns : void
+ *
+ *********************************************************************/
+void set_keep_alive_timeout(int timeout)
+{
+ keep_alive_timeout = timeout;
+}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
#ifndef GATEWAY_H_INCLUDED
#define GATEWAY_H_INCLUDED
-#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.9 2006/07/18 14:48:46 david__schmidt Exp $"
+#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.10 2008/10/09 18:21:41 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.h,v $
*
* Revisions :
* $Log: gateway.h,v $
+ * Revision 1.10 2008/10/09 18:21:41 fabiankeil
+ * Flush work-in-progress changes to keep outgoing connections
+ * alive where possible. Incomplete and mostly #ifdef'd out.
+ *
* Revision 1.9 2006/07/18 14:48:46 david__schmidt
* Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
* with what was really the latest development (the v_3_0_branch branch)
struct http_request *http,
struct client_state *csp);
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+
+/*
+ * Default number of seconds after which an
+ * open connection will no longer be reused.
+ */
+#define DEFAULT_KEEP_ALIVE_TIMEOUT 180
+
+extern void set_keep_alive_timeout(int timeout);
extern void initialize_reusable_connections(void);
extern void forget_connection(jb_socket sfd);
extern void remember_connection(jb_socket sfd,
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.79 2008/08/30 12:03:07 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.80 2008/08/31 15:59:03 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.80 2008/08/31 15:59:03 fabiankeil
+ * There's no reason to let remote toggling support depend
+ * on FEATURE_CGI_EDIT_ACTIONS, so make sure it doesn't.
+ *
* Revision 1.79 2008/08/30 12:03:07 fabiankeil
* Remove FEATURE_COOKIE_JAR.
*
#include "encode.h"
#include "urlmatch.h"
#include "cgi.h"
+#include "gateway.h"
const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
#define hash_forward_socks5 3963965522ul /* "forward-socks5" */
#define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
#define hash_hostname 10308071ul /* "hostname" */
+#define hash_keep_alive_timeout 3878599515ul /* "keep-alive-timeout" */
#define hash_listen_address 1255650842ul /* "listen-address" */
#define hash_logdir 422889ul /* "logdir" */
#define hash_logfile 2114766ul /* "logfile" */
unsigned long linenum = 0;
int i;
char *logfile = NULL;
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ int keep_alive_timeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
+#endif
if ( !check_file_changed(current_configfile, configfile, &fs))
{
}
continue;
+/* *************************************************************************
+ * keep-alive-timeout timeout
+ * *************************************************************************/
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ case hash_keep_alive_timeout :
+ if (*arg != '\0')
+ {
+ int timeout = atoi(arg);
+ if (0 <= timeout)
+ {
+ keep_alive_timeout = timeout;
+ }
+ else
+ {
+ log_error(LOG_LEVEL_FATAL,
+ "Invalid keep-alive-timeout value: %s.", arg);
+ }
+ }
+ continue;
+#endif
+
/* *************************************************************************
* listen-address [ip][:port]
* *************************************************************************/
fclose(configfp);
set_debug_level(config->debug);
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ set_keep_alive_timeout(keep_alive_timeout);
+#endif
freez(config->logfile);