mturk 2004/11/12 10:45:24
Modified: jk/native/apache-1.3 mod_jk.c
jk/native/apache-2.0 mod_jk.c
jk/native/common jk_ajp_common.c jk_service.h jk_util.c
jk_util.h
jk/native/iis jk_isapi_plugin.c
Log:
Added custom 'retries' for worker, so we don't depend on
default setting. If set to a number grater then 3, it will sleep
for 100ms on retry greater then 3 and then try again.
Revision Changes Path
1.52 +3 -1 jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c
Index: mod_jk.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- mod_jk.c 12 Nov 2004 08:42:47 -0000 1.51
+++ mod_jk.c 12 Nov 2004 18:45:24 -0000 1.52
@@ -1554,6 +1554,8 @@
jk_init_ws_service(&s);
+ /* Update retries for this worker */
+ s.retries = worker->retries;
s.ws_private = &private_data;
s.pool = &private_data.p;
#ifndef NO_GETTIMEOFDAY
1.101 +5 -2 jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c
Index: mod_jk.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- mod_jk.c 12 Nov 2004 09:02:04 -0000 1.100
+++ mod_jk.c 12 Nov 2004 18:45:24 -0000 1.101
@@ -1732,7 +1732,9 @@
}
if (worker) {
+#ifndef NO_GETTIMEOFDAY
struct timeval tv_begin, tv_end;
+#endif
int rc = JK_FALSE;
apache_private_data_t private_data;
jk_ws_service_t s;
@@ -1744,7 +1746,8 @@
private_data.r = r;
jk_init_ws_service(&s);
-
+ /* Update retries for this worker */
+ s.retries = worker->retries;
s.ws_private = &private_data;
s.pool = &private_data.p;
#ifndef NO_GETTIMEOFDAY
1.63 +39 -5
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.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- jk_ajp_common.c 12 Nov 2004 12:47:37 -0000 1.62
+++ jk_ajp_common.c 12 Nov 2004 18:45:24 -0000 1.63
@@ -35,6 +35,24 @@
#include "novsock2.h"
#endif
+/* Sleep for 100ms */
+static void jk_sleep_def()
+{
+#ifdef OS2
+ DosSleep(100);
+#elif defined(BEOS)
+ snooze(100 * 1000);
+#elif defined(NETWARE)
+ delay(100);
+#elif defined(WIN32)
+ Sleep(100);
+#else
+ struct timeval tv;
+ tv.tv_usec = 100 * 1000;
+ tv.tv_sec = 0;
+ select(0, NULL, NULL, NULL, &tv);
+#endif
+}
const char *response_trans_headers[] = {
"Content-Type",
@@ -1442,8 +1460,6 @@
return JK_FALSE;
}
-#define JK_RETRIES 3
-
/*
* service is now splitted in ajp_send_request and ajp_get_reply
* much more easier to do errors recovery
@@ -1497,7 +1513,7 @@
* JK_RETRIES could be replaced by the number of workers in
* a load-balancing configuration
*/
- for (i = 0; i < JK_RETRIES; i++) {
+ for (i = 0; i < s->retries; i++) {
/*
* We're using reqmsg which hold initial request
* if Tomcat is stopped or restarted, we will pass reqmsg
@@ -1546,6 +1562,10 @@
jk_log(l, JK_LOG_INFO,
"Receiving from tomcat failed, "
"recoverable operation attempt=%d\n", i);
+ /* Check for custom retries */
+ if (i >= JK_RETRIES) {
+ jk_sleep_def();
+ }
}
}
@@ -1562,8 +1582,8 @@
}
else {
jk_log(l, JK_LOG_INFO,
- "sending request to tomcat failed in send loop. "
- "retry=%d\n", i);
+ "Sending request to tomcat failed, "
+ "recoverable operation attempt=%d\n", i);
}
}
@@ -1728,6 +1748,20 @@
"setting recovery opts to %d\n",
p->recovery_opts);
+ pThis->retries =
+ jk_get_worker_retries(props, p->name,
+ JK_RETRIES);
+ if (pThis->retries < 1) {
+ jk_log(l, JK_LOG_INFO,
+ "number of retries must be grater then 1. Setting to
default=%d\n",
+ JK_RETRIES);
+ pThis->retries = JK_RETRIES;
+ }
+ else {
+ jk_log(l, JK_LOG_DEBUG,
+ "setting number of retries to %d\n",
+ pThis->retries);
+ }
/*
* Need to initialize secret here since we could return from inside
* of the following loop
1.20 +11 -1 jakarta-tomcat-connectors/jk/native/common/jk_service.h
Index: jk_service.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_service.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- jk_service.h 8 Nov 2004 13:33:21 -0000 1.19
+++ jk_service.h 12 Nov 2004 18:45:24 -0000 1.20
@@ -34,6 +34,8 @@
#include "jk_uri_worker_map.h"
#include "jk_msg_buff.h"
+#define JK_RETRIES 3
+
#ifdef __cplusplus
extern "C"
{
@@ -210,6 +212,9 @@
jk_msg_buf_t *reco_buf;
int reco_status;
+ /* Number of retries. Defaults to JK_RETRIES
+ */
+ int retries;
/*
* Send the response headers to the browser.
*/
@@ -340,6 +345,11 @@
struct jk_worker
{
+ /*
+ * Public property to enable the number of retry attempts
+ * on this worker.
+ */
+ int retries;
/*
* A 'this' pointer which is used by the subclasses of this class to
* point to data/functions which are specific to a given protocol
1.38 +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.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- jk_util.c 12 Nov 2004 07:52:23 -0000 1.37
+++ jk_util.c 12 Nov 2004 18:45:24 -0000 1.38
@@ -60,6 +60,7 @@
#define WORKER_AJP12 ("ajp12")
#define DEFAULT_WORKER_TYPE JK_AJP12_WORKER_NAME
#define SECRET_KEY_OF_WORKER ("secretkey")
+#define RETRIES_OF_WORKER ("retries")
#define DEFAULT_WORKER JK_AJP12_WORKER_NAME
#define WORKER_LIST_PROPERTY_NAME ("worker.list")
@@ -522,6 +523,20 @@
return jk_map_get_int(m, buf, def);
}
+int jk_get_worker_retries(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,
+ RETRIES_OF_WORKER);
+
+ return jk_map_get_int(m, buf, def);
+}
+
int jk_get_worker_recovery_opts(jk_map_t *m, const char *wname, int def)
{
char buf[1024];
@@ -988,4 +1003,5 @@
s->attributes_values = NULL;
s->num_attributes = 0;
s->jvm_route = NULL;
+ s->retries = JK_RETRIES;
}
1.21 +3 -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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- jk_util.h 11 Nov 2004 09:44:29 -0000 1.20
+++ jk_util.h 12 Nov 2004 18:45:24 -0000 1.21
@@ -72,6 +72,8 @@
char *jk_get_worker_secret_key(jk_map_t *m, const char *wname);
+int jk_get_worker_retries(jk_map_t *m, const char *wname, int def);
+
void jk_set_log_format(const char *logformat);
int jk_get_worker_list(jk_map_t *m, char ***list, unsigned *num_of_wokers);
1.29 +3 -1 jakarta-tomcat-connectors/jk/native/iis/jk_isapi_plugin.c
Index: jk_isapi_plugin.c
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/native/iis/jk_isapi_plugin.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- jk_isapi_plugin.c 12 Nov 2004 11:56:18 -0000 1.28
+++ jk_isapi_plugin.c 12 Nov 2004 18:45:24 -0000 1.29
@@ -888,6 +888,8 @@
if (worker) {
jk_endpoint_t *e = NULL;
+ /* Update retries for this worker */
+ s.retries = worker->retries;
if (worker->get_endpoint(worker, &e, logger)) {
int recover = JK_FALSE;
if (e->service(e, &s, logger, &recover)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]