If the server doesn't specify how long the connection stays alive, err on the safe...
authorFabian Keil <fk@fabiankeil.de>
Tue, 14 Jul 2009 17:50:34 +0000 (17:50 +0000)
committerFabian Keil <fk@fabiankeil.de>
Tue, 14 Jul 2009 17:50:34 +0000 (17:50 +0000)
jcc.c
parsers.c
project.h

diff --git a/jcc.c b/jcc.c
index a9da886..adb5bee 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.269 2009/07/13 17:08:41 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.270 2009/07/13 17:12:28 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -2350,6 +2350,14 @@ static void serve(struct client_state *csp)
    {
       chat(csp);
 
+      if ((csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE)
+         && !(csp->flags & CSP_FLAG_SERVER_KEEP_ALIVE_TIMEOUT_SET))
+      {
+         log_error(LOG_LEVEL_CONNECT, "The server didn't specify how long "
+            "the connection will stay open. Assume it's only a second.");
+         csp->server_connection.keep_alive_timeout = 1;
+      }
+
       continue_chatting = (csp->config->feature_flags
          & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE)
          && (csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE)
index ef0fde2..ca0eb5c 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.196 2009/07/11 11:20:12 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.197 2009/07/13 17:10:57 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -1664,6 +1664,7 @@ static jb_err server_keep_alive(struct client_state *csp, char **header)
             "Server keep-alive timeout is %u. Sticking with %u.",
             keep_alive_timeout, csp->server_connection.keep_alive_timeout);
       }
+      csp->flags |= CSP_FLAG_SERVER_KEEP_ALIVE_TIMEOUT_SET;
    }
 
    return JB_ERR_OK;
index 554abbb..6e24ed2 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.145 2009/07/13 19:16:15 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.146 2009/07/14 17:45:05 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -768,13 +768,19 @@ struct reusable_connection
  */
 #define CSP_FLAG_CLIENT_REQUEST_COMPLETELY_READ 0x00010000U
 
+/**
+ * Flag for csp->flags: Set if the server promised us to
+ * keep the connection open for a known number of seconds.
+ */
+#define CSP_FLAG_SERVER_KEEP_ALIVE_TIMEOUT_SET  0x00020000U
+
 #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
 
 /**
  * Flag for csp->flags: Set if we think we can't reuse
  * the server socket.
  */
-#define CSP_FLAG_SERVER_SOCKET_TAINTED          0x00020000U
+#define CSP_FLAG_SERVER_SOCKET_TAINTED          0x00040000U
 
 /*
  * Flags for use in return codes of child processes