Respect the server's keep-alive value if it's below ours.
[privoxy.git] / gateway.h
index 9897044..3868c2b 100644 (file)
--- 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.3 2001/07/29 18:58:15 jongfoster Exp $"
+#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.14 2009/05/13 18:20:54 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/gateway.h,v $
@@ -10,7 +10,7 @@
  *                proxy).  Also contains the list of gateway types.
  *
  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
- *                IJBSWA team.  http://ijbswa.sourceforge.net
+ *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
  *                by and Copyright (C) 1997 Anonymous Coders and 
  *
  * Revisions   :
  *    $Log: gateway.h,v $
+ *    Revision 1.14  2009/05/13 18:20:54  fabiankeil
+ *    There's no reason for keep_alive_timeout to be signed.
+ *
+ *    Revision 1.13  2009/05/10 10:12:30  fabiankeil
+ *    Initial keep-alive support for the client socket.
+ *    Temporarily disable the server-side-only keep-alive code.
+ *
+ *    Revision 1.12  2008/12/24 17:06:19  fabiankeil
+ *    Keep a thread around to timeout alive connections
+ *    even if no new requests are coming in.
+ *
+ *    Revision 1.11  2008/11/13 09:08:42  fabiankeil
+ *    Add new config option: keep-alive-timeout.
+ *
+ *    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)
+ *
+ *    Revision 1.7  2002/03/26 22:29:54  swa
+ *    we have a new homepage!
+ *
+ *    Revision 1.6  2002/03/25 22:12:45  oes
+ *    Added fix for undefined INADDR_NONE on Solaris by Bart Schelstraete
+ *
+ *    Revision 1.5  2002/03/24 13:25:43  swa
+ *    name change related issues
+ *
+ *    Revision 1.4  2002/03/09 20:03:52  jongfoster
+ *    - Making various functions return int rather than size_t.
+ *      (Undoing a recent change).  Since size_t is unsigned on
+ *      Windows, functions like read_socket that return -1 on
+ *      error cannot return a size_t.
+ *
+ *      THIS WAS A MAJOR BUG - it caused frequent, unpredictable
+ *      crashes, and also frequently caused JB to jump to 100%
+ *      CPU and stay there.  (Because it thought it had just
+ *      read ((unsigned)-1) == 4Gb of data...)
+ *
+ *    - The signature of write_socket has changed, it now simply
+ *      returns success=0/failure=nonzero.
+ *
+ *    - Trying to get rid of a few warnings --with-debug on
+ *      Windows, I've introduced a new type "jb_socket".  This is
+ *      used for the socket file descriptors.  On Windows, this
+ *      is SOCKET (a typedef for unsigned).  Everywhere else, it's
+ *      an int.  The error value can't be -1 any more, so it's
+ *      now JB_INVALID_SOCKET (which is -1 on UNIX, and in
+ *      Windows it maps to the #define INVALID_SOCKET.)
+ *
+ *    - The signature of bind_port has changed.
+ *
  *    Revision 1.3  2001/07/29 18:58:15  jongfoster
  *    Removing nested #includes, adding forward declarations for needed
  *    structures, and changing the #define _FILENAME_H to FILENAME_H_INCLUDED.
@@ -66,8 +121,39 @@ 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
+ * open connection will no longer be reused.
+ */
+#define DEFAULT_KEEP_ALIVE_TIMEOUT 180
+
+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(jb_socket sfd,
+                                const struct http_request *http,
+                                const struct forward_spec *fwd,
+                                unsigned int timeout);
+extern int close_unusable_connections(void);
+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 */
 
-/* Revision control strings from this header and associated .c file */
+
+/*
+ * Solaris fix
+ */
+#ifndef INADDR_NONE
+#define INADDR_NONE -1
+#endif
+
+/*
+ * Revision control strings from this header and associated .c file
+ */
 extern const char gateway_rcs[];
 extern const char gateway_h_rcs[];