From 640ef193745c0bab70ded93c34dff846655aa73f Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 14 Jul 2009 17:50:34 +0000 Subject: [PATCH] If the server doesn't specify how long the connection stays alive, err on the safe side of caution and assume it's only a second. --- jcc.c | 10 +++++++++- parsers.c | 3 ++- project.h | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jcc.c b/jcc.c index a9da886e..adb5beeb 100644 --- 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) diff --git a/parsers.c b/parsers.c index ef0fde2d..ca0eb5c6 100644 --- 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; diff --git a/project.h b/project.h index 554abbb3..6e24ed2c 100644 --- 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 -- 2.39.2