From tomcat-dev-return-40241-apmail-jakarta-tomcat-dev-archive=jakarta.apache.org@jakarta.apache.org Tue Feb 17 10:36:09 2004 Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 38480 invoked from network); 17 Feb 2004 10:36:09 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 17 Feb 2004 10:36:09 -0000 Received: (qmail 24429 invoked by uid 500); 17 Feb 2004 10:35:35 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 24367 invoked by uid 500); 17 Feb 2004 10:35:35 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 24354 invoked by uid 500); 17 Feb 2004 10:35:35 -0000 Received: (qmail 24351 invoked from network); 17 Feb 2004 10:35:35 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 17 Feb 2004 10:35:35 -0000 Received: (qmail 38453 invoked by uid 1198); 17 Feb 2004 10:36:01 -0000 Date: 17 Feb 2004 10:36:01 -0000 Message-ID: <20040217103601.38452.qmail@minotaur.apache.org> From: hgomez@apache.org To: jakarta-tomcat-connectors-cvs@apache.org Subject: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_util.c jk_util.h jk_ajp_common.h jk_ajp_common.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hgomez 2004/02/17 02:36:01 Modified: jk/native/common jk_util.c jk_util.h jk_ajp_common.h jk_ajp_common.c Log: Make recovery scheme configurable : - We could abort recovery if tomcat failed after receiving request or if tomcat failed after send headers. (For now we keep the default behaviour, recover allways) Revision Changes Path 1.26 +17 -1 jakarta-tomcat-connectors/jk/native/common/jk_util.c Index: jk_util.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- jk_util.c 5 Nov 2003 09:15:39 -0000 1.25 +++ jk_util.c 17 Feb 2004 10:36:00 -0000 1.26 @@ -85,6 +85,7 @@ #define TYPE_OF_WORKER ("type") #define CACHE_OF_WORKER ("cachesize") #define CACHE_TIMEOUT_OF_WORKER ("cache_timeout") +#define RECOVERY_OPTS_OF_WORKER ("recovery_options") #define CONNECT_TIMEOUT_OF_WORKER ("connect_timeout") #define PREPOST_TIMEOUT_OF_WORKER ("prepost_timeout") #define REPLY_TIMEOUT_OF_WORKER ("reply_timeout") @@ -488,6 +489,21 @@ } sprintf(buf, "%s.%s.%s", PREFIX_OF_WORKER, wname, REPLY_TIMEOUT_OF_WORKER); + + return map_get_int(m, buf, def); +} + +int jk_get_worker_recovery_opts(jk_map_t *m, + const char *wname, + int def) +{ + char buf[1024]; + + if(!m || !wname) { + return -1; + } + + sprintf(buf, "%s.%s.%s", PREFIX_OF_WORKER, wname, RECOVERY_OPTS_OF_WORKER); return map_get_int(m, buf, def); } 1.15 +5 -1 jakarta-tomcat-connectors/jk/native/common/jk_util.h Index: jk_util.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- jk_util.h 4 Feb 2004 16:37:06 -0000 1.14 +++ jk_util.h 17 Feb 2004 10:36:00 -0000 1.15 @@ -122,6 +122,10 @@ const char *wname, int def); +int jk_get_worker_recovery_opts(jk_map_t *m, + const char *wname, + int def); + int jk_get_worker_connect_timeout(jk_map_t *m, const char *wname, int def); 1.22 +12 -1 jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.h Index: jk_ajp_common.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- jk_ajp_common.h 5 Nov 2003 09:15:39 -0000 1.21 +++ jk_ajp_common.h 17 Feb 2004 10:36:00 -0000 1.22 @@ -232,6 +232,12 @@ #define AJP_DEF_CONNECT_TIMEOUT (0) /* NO CONNECTION TIMEOUT => NO CPING/CPONG */ #define AJP_DEF_REPLY_TIMEOUT (0) /* NO REPLY TIMEOUT */ #define AJP_DEF_PREPOST_TIMEOUT (0) /* NO PREPOST TIMEOUT => NO CPING/CPONG */ +#define AJP_DEF_RECOVERY_OPTS (0) /* NO RECOVERY / NO */ + +#define RECOVER_ABORT_IF_TCGETREQUEST 0x0001 /* DONT RECOVER IF TOMCAT FAIL AFTER RECEIVING REQUEST */ +#define RECOVER_ABORT_IF_TCSENDHEADER 0x0002 /* DONT RECOVER IF TOMCAT FAIL AFTER SENDING HEADERS */ + + struct jk_res_data { int status; @@ -307,6 +313,11 @@ unsigned connect_timeout; /* connect cping/cpong delay in ms (0 means disabled) */ unsigned reply_timeout; /* reply timeout delay in ms (0 means disabled) */ unsigned prepost_timeout; /* before sending a request cping/cpong timeout delay in ms (0 means disabled) */ + + /* + * Recovery option + */ + unsigned recovery_opts; /* Set the recovery option */ }; 1.48 +65 -7 jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c Index: jk_ajp_common.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- jk_ajp_common.c 11 Feb 2004 09:49:49 -0000 1.47 +++ jk_ajp_common.c 17 Feb 2004 10:36:00 -0000 1.48 @@ -1174,7 +1174,7 @@ (const char * const *)res.header_values, res.num_headers); } - break; + return JK_AJP13_SEND_HEADERS; case JK_AJP13_SEND_BODY_CHUNK: { @@ -1261,6 +1261,9 @@ ajp_endpoint_t *p, ajp_operation_t *op) { + /* Don't get header from tomcat yet */ + int headeratclient = JK_FALSE; + /* Start read all reply message */ while(1) { int rc = 0; @@ -1279,18 +1282,66 @@ } if(!ajp_connection_tcp_get_message(p, op->reply, l)) { + /* we just can't recover, unset recover flag */ + if(headeratclient == JK_FALSE) { jk_log(l, JK_LOG_ERROR, + "Tomcat is down or network problems. " + "No response has been sent to the client (yet)\n"); + /* + * communication with tomcat has been interrupted BEFORE + * headers have been sent to the client. + * DISCUSSION: As we suppose that tomcat has already started + * to process the query we think it's unrecoverable (and we + * should not retry or switch to another tomcat in the + * cluster). + */ + + /* + * We mark it unrecoverable if recovery_opts set to RECOVER_ABORT_IF_TCGETREQUEST + */ + if (p->worker->recovery_opts & RECOVER_ABORT_IF_TCGETREQUEST) + op->recoverable = JK_FALSE; + /* + * we want to display the webservers error page, therefore + * we return JK_FALSE + */ + return JK_FALSE; + + } else { + jk_log(l, JK_LOG_ERROR, "Error reading reply from tomcat. " - "Tomcat is down or network problems.\n"); - /* we just can't recover, unset recover flag */ - return JK_FALSE; - } - + "Tomcat is down or network problems. " + "Part of the response has already been sent to the client\n"); + + /* communication with tomcat has been interrupted AFTER + * headers have been sent to the client. + * headers (and maybe parts of the body) have already been + * sent, therefore the response is "complete" in a sense + * that nobody should append any data, especially no 500 error + * page of the webserver! + * + * BUT if you retrun JK_TRUE you have a 200 (OK) code in your + * in your apache access.log instead of a 500 (Error). + * Therefore return FALSE/FALSE + * return JK_TRUE; + */ + + /* + * We mark it unrecoverable if recovery_opts set to RECOVER_ABORT_IF_TCSENDHEADER + */ + if (p->worker->recovery_opts & RECOVER_ABORT_IF_TCSENDHEADER) + op->recoverable = JK_FALSE; + + return JK_FALSE; + } + rc = ajp_process_callback(op->reply, op->post, p, s, l); /* no more data to be sent, fine we have finish here */ if(JK_AJP13_END_RESPONSE == rc) { return JK_TRUE; + } else if(JK_AJP13_SEND_HEADERS == rc) { + headeratclient = JK_TRUE; } else if(JK_AJP13_HAS_RESPONSE == rc) { /* * in upload-mode there is no second chance since @@ -1597,6 +1648,13 @@ jk_log(l, JK_LOG_DEBUG, "In jk_worker_t::init, setting prepost timeout to %d\n", p->prepost_timeout); + + p->recovery_opts = + jk_get_worker_recovery_opts(props, p->name, AJP_DEF_RECOVERY_OPTS); + + jk_log(l, JK_LOG_DEBUG, + "In jk_worker_t::init, setting recovery opts to %d\n", + p->recovery_opts); /* * Need to initialize secret here since we could return from inside --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org