Author: mturk
Date: Fri Mar 23 08:35:18 2007
New Revision: 521770

URL: http://svn.apache.org/viewvc?view=rev&rev=521770
Log:
Allow multiple status codes for fail_on_status directive.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
    tomcat/connectors/trunk/jk/native/common/jk_map.c
    tomcat/connectors/trunk/jk/native/common/jk_map.h
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/native/common/jk_util.h
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Fri Mar 23 
08:35:18 2007
@@ -1443,7 +1443,7 @@
                 if (r->flush)
                     r->flush(r);
             }
-            else {            
+            else {
                 if (!r->write(r, msg->buf + msg->pos, len)) {
                     jk_log(l, JK_LOG_INFO,
                            "Writing to client aborted or client network 
problems");
@@ -1526,6 +1526,17 @@
     return JK_AJP13_NO_RESPONSE;
 }
 
+static int is_http_status_fail(ajp_worker_t *w, int status)
+{
+    unsigned int i;
+    for (i = 0; i < w->http_status_fail_num; i++) {
+        if (w->http_status_fail[i] == status)
+            return 1;
+    }
+    return 0;
+}
+
+
 /*
  * get replies from Tomcat via Ajp13/Ajp14
  * We will know only at read time if the remote host closed
@@ -1641,8 +1652,7 @@
             return JK_TRUE;
         }
         else if (JK_AJP13_SEND_HEADERS == rc) {
-            if (p->worker->http_status_fail &&
-                (p->worker->http_status_fail == s->http_response_status)) {
+            if (is_http_status_fail(p->worker, s->http_response_status)) {
                 JK_TRACE_EXIT(l);
                 return JK_STATUS_ERROR;
             }
@@ -1868,7 +1878,7 @@
                        "because of response status %d, "
                        "recoverable operation attempt=%d",
                        p->worker->name,
-                       p->worker->http_status_fail, i);
+                       s->http_response_status, i);
                 JK_TRACE_EXIT(l);
                 if (i >= JK_RETRIES) {
                     jk_sleep(JK_SLEEP_DEF);
@@ -2096,7 +2106,10 @@
         p->max_packet_size =
             jk_get_max_packet_size(props, p->name);
 
-        p->http_status_fail = jk_get_worker_fail_on_status(props, p->name);
+        p->http_status_fail_num = jk_get_worker_fail_on_status(props, p->name,
+                                     &p->http_status_fail[0],
+                                     JK_MAX_HTTP_STATUS_FAILS);
+
 
         pThis->retries =
             jk_get_worker_retries(props, p->name,
@@ -2237,7 +2250,7 @@
             int i;
             jk_sock_t sock = JK_INVALID_SOCKET;
 
-            /* If we are going to close the connection, then park the socket 
so 
+            /* If we are going to close the connection, then park the socket so
                we can shut it down nicely rather than letting 
ajp_reset_endpoint kill it */
             if (IS_VALID_SOCKET(p->sd) && !p->reuse) {
                 if (JK_IS_DEBUG_LEVEL(l))

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Fri Mar 23 
08:35:18 2007
@@ -201,7 +201,7 @@
 #define RECOVER_ABORT_IF_TCSENDHEADER    0x0002 /* DONT RECOVER IF TOMCAT FAIL 
AFTER SENDING HEADERS */
 #define RECOVER_ABORT_IF_CLIENTERROR     0x0004 /* CLOSE THE SOCKET IN CASE OF 
CLIENT ERROR */
 
-
+#define JK_MAX_HTTP_STATUS_FAILS   32   /* Should be enough for most 400 and 
500 statuses */
 
 struct jk_res_data
 {
@@ -291,7 +291,8 @@
     /* 
      * HTTP status that will cause failover (0 means disabled)
      */
-     int http_status_fail;
+     unsigned int http_status_fail_num;
+     int http_status_fail[JK_MAX_HTTP_STATUS_FAILS];
 };
 
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_map.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_map.c?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_map.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_map.c Fri Mar 23 08:35:18 2007
@@ -244,7 +244,7 @@
 
 char **jk_map_get_string_list(jk_map_t *m,
                               const char *name,
-                              unsigned *list_len, const char *def)
+                              unsigned int *list_len, const char *def)
 {
     const char *l = jk_map_get_string(m, name, def);
     char **ar = NULL;
@@ -295,6 +295,55 @@
     }
 
     return ar;
+}
+
+int jk_map_get_int_list(jk_map_t *m,
+                        const char *name,
+                        int *list,
+                        unsigned int list_len,
+                        const char *def)
+{
+    const char *l = jk_map_get_string(m, name, def);
+
+#if defined(AS400) || defined(_REENTRANT)
+    char *lasts;
+#endif
+    
+    if (!list_len)
+        return 0;
+
+    if (l) {
+        unsigned int capacity = list_len;
+        unsigned int index = 0;
+        char *p;
+        char *v = jk_pool_strdup(&m->p, l);
+
+        if (!v) {
+            return 0;
+        }
+
+        /*
+         * GS, in addition to VG's patch, we now need to
+         * strtok also by a "*"
+         */
+#if defined(AS400) || defined(_REENTRANT)
+        for (p = strtok_r(v, " \t,", &lasts);
+             p; p = strtok_r(NULL, " \t,", &lasts))
+#else
+        for (p = strtok(v, " \t,"); p; p = strtok(NULL, " \t,"))
+#endif
+
+        {
+            if (index < capacity) {
+                list[index] = atoi(p);
+                index++;
+            }
+            else
+                break;                
+        }
+        return index;
+    }
+    return 0;
 }
 
 int jk_map_add(jk_map_t *m, const char *name, const void *value)

Modified: tomcat/connectors/trunk/jk/native/common/jk_map.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_map.h?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_map.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_map.h Fri Mar 23 08:35:18 2007
@@ -58,6 +58,11 @@
                            const char *name,
                            unsigned *list_len, const char *def);
 
+int jk_map_get_int_list(jk_map_t *m,
+                        const char *name,
+                        int *list, unsigned int list_len,
+                        const char *def);
+
 int jk_map_add(jk_map_t *m, const char *name, const void *value);
 
 int jk_map_put(jk_map_t *m, const char *name, const void *value, void **old);

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Fri Mar 23 08:35:18 2007
@@ -1080,17 +1080,21 @@
     return sz;
 }
 
-int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname)
+int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname,
+                                 int *list, unsigned int list_size)
 {
     char buf[1024];
-
-    if (!m || !wname) {
+    if (!m || !wname || !list) {
         return 0;
     }
-
     MAKE_WORKER_PARAM(STATUS_FAIL_OF_WORKER);
-    return jk_map_get_int(m, buf, 0);
+    if (list_size) {
+        return jk_map_get_int_list(m, buf,
+                                   list, list_size,
+                                   NULL);
+    }
 
+    return 0;
 }
 
 int jk_get_worker_user_case_insensitive(jk_map_t *m, const char *wname)

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.h?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Fri Mar 23 08:35:18 2007
@@ -199,7 +199,9 @@
 
 const char *jk_get_worker_prop_prefix(jk_map_t *m, const char *wname, const 
char *def);
 
-int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname);
+int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname,
+                                 int *list, unsigned int list_size);
+
 
 int jk_get_worker_user_case_insensitive(jk_map_t *m, const char *wname);
 

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?view=diff&rev=521770&r1=521769&r2=521770
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Fri Mar 23 
08:35:18 2007
@@ -27,6 +27,10 @@
   <subsection name="Native">
     <changelog>
       <update>
+      Allow multiple status codes for fail_on_status directive.
+      The status codes can be delimited by space or coma characters. (mturk)
+      </update>
+      <update>
         IIS. Added pcre like regular expressions for url rewrite rules. (mturk)
       </update>
       <fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to